[fix] missed corrections
authorOlivier Dony <odo@openerp.com>
Tue, 16 Mar 2010 08:58:06 +0000 (09:58 +0100)
committerXavier Morel <xmo@tinyerp.com>
Tue, 16 Mar 2010 08:58:06 +0000 (09:58 +0100)
bzr revid: xmo@tinyerp.com-20100316085806-fm2u5qy1akd53rfb

addons/account/project/report/analytic_balance.py
addons/account/report/general_journal.py
addons/account/wizard/wizard_account_balance_report.py
addons/account_analytic_plans/report/crossovered_analytic.py
addons/account_payment/payment.py
addons/crm_profiling/crm_profiling.py
addons/event_project/event.py
addons/membership/wizard/invoice_membership.py
addons/stock/stock.py

index c6b4807..3cc2cba 100644 (file)
@@ -102,22 +102,20 @@ class account_analytic_balance(report_sxw.rml_parse):
             self.acc_data_dict[account_id] = ids
         else:
             ids = self.acc_data_dict[account_id]
-        
+
+        query_params = (tuple(ids), date1, date2)
         if option == "credit" :
             self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \
                     WHERE account_id in %s \
-                        AND date>=%s AND date<=%s AND amount<0",
-                    (tuple(ids),date1, date2))
+                        AND date>=%s AND date<=%s AND amount<0", query_params)
         elif option == "debit" :
             self.cr.execute("SELECT sum(amount) FROM account_analytic_line \
                     WHERE account_id in %s \
-                        AND date>=%s AND date<=%s AND amount>0",
-                    (tuple(ids), date1, date2))
+                        AND date>=%s AND date<=%s AND amount>0", query_params)
         elif option == "quantity" :
             self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \
-                WHERE account_id in %s \
-                    AND date>=%s AND date<=%s",
-                (tuple(ids), date1, date2))
+                    WHERE account_id in %s \
+                        AND date>=%s AND date<=%s", query_params)
         return self.cr.fetchone()[0] or 0.0
 
     def _move_sum_balance(self, account_id, date1, date2):
@@ -138,21 +136,19 @@ class account_analytic_balance(report_sxw.rml_parse):
         else:
             ids2 = self.acc_sum_list
 
+        query_params = (tuple(ids2), date1, date2)
         if option == "debit" :
             self.cr.execute("SELECT sum(amount) FROM account_analytic_line \
                     WHERE account_id IN %s \
-                        AND date>=%s AND date<=%s AND amount>0",
-                    (tuple(ids2), date1, date2))
+                        AND date>=%s AND date<=%s AND amount>0", query_params)
         elif option == "credit" :
             self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \
                     WHERE account_id IN %s \
-                        AND date>=%s AND date<=%s AND amount<0",
-                    (tuple(ids2), date1, date2))
+                        AND date>=%s AND date<=%s AND amount<0", query_params)
         elif option == "quantity" :
             self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \
                     WHERE account_id IN %s \
-                        AND date>=%s AND date<=%s",
-                    (tuple(ids2), date1, date2))
+                        AND date>=%s AND date<=%s", query_params)
         return self.cr.fetchone()[0] or 0.0
 
     def _sum_balance(self, accounts, date1, date2):
index 9d6bccc..fb2f52d 100644 (file)
@@ -105,7 +105,7 @@ class journal_print(report_sxw.rml_parse):
 
     def _sum_debit_period(self, period_id,journal_id=None):
         journals = journal_id or self.journal_ids
-        if not self.journals:
+        if not journals:
             return 0.0
         self.cr.execute('SELECT SUM(debit) FROM account_move_line '
                         'WHERE period_id=%s AND journal_id IN %s '
@@ -115,7 +115,7 @@ class journal_print(report_sxw.rml_parse):
 
     def _sum_credit_period(self, period_id,journal_id=None):
         journals = journal_id or self.journal_ids
-        if not self.journals:
+        if not journals:
             return 0.0
         self.cr.execute('SELECT SUM(credit) FROM account_move_line '
                         'WHERE period_id=%s AND journal_id IN %s '
index 6f8e74d..af6ad17 100644 (file)
@@ -113,7 +113,7 @@ class wizard_report(wizard.interface):
     def _check_date(self, cr, uid, data, context):
         sql = """
             SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f  Where %s between f.date_start and f.date_stop """
-        cr.execute(sql, (data['form']['date_from']))
+        cr.execute(sql, (data['form']['date_from'],))
         res = cr.dictfetchall()
         if res:
             if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):
index 2601db9..25f668f 100644 (file)
@@ -153,8 +153,8 @@ class crossovered_analytic(report_sxw.rml_parse):
                        "WHERE aal.account_id=aaa.id "\
                        "AND aal.id IN %%s "\
                        "AND (aal.journal_id %s) "\
-                       "AND aal.date>=%s "\
-                       "AND aal.date<=%s "\
+                       "AND aal.date>=%%s "\
+                       "AND aal.date<=%%s "\
                        "GROUP BY aal.account_id, aaa.name, aaa.code "\
                        "ORDER BY aal.account_id" % (
                     journal_filter
index 1691b33..ce74362 100644 (file)
@@ -211,7 +211,7 @@ class payment_line(osv.osv):
             from account_move_line ml
                 inner join payment_line pl
                 on (ml.id = pl.move_line_id)
-            where pl.id in (%s)"""% self.translate(name),
+            where pl.id in %%s"""% self.translate(name),
                    (tuple(ids),))
         res = dict(cr.fetchall())
 
index 2a04a41..fd9da3e 100644 (file)
@@ -36,9 +36,9 @@ def _get_answers(cr, uid, ids):
     query = """
     select distinct(answer)
     from profile_question_no_rel
-    where profile in (%s)"""% ','.join([str(i) for i in ids ])
+    where profile in %s"""
 
-    cr.execute(query)
+    cr.execute(query, (tuple(ids),))
     ans_no = [x[0] for x in cr.fetchall()]
 
     return [ans_yes, ans_no]
@@ -87,30 +87,31 @@ def test_prof(cr, uid, seg_id, pid, answers_ids = []):
 
 
 def _recompute_categ(self, cr, uid, pid, answers_ids):
-    ok =  []
     cr.execute('''
-        select r.category_id 
+        select r.category_id
         from res_partner_category_rel r left join crm_segmentation s on (r.category_id = s.categ_id) 
         where r.partner_id = %s and (s.exclusif = false or s.exclusif is null)
         ''', (pid,))
-    for x in cr.fetchall():
-        ok.append(x[0])
+    categories = [x[0] for x in cr.fetchall()]
 
     query = '''
-        select id, categ_id 
-        from crm_segmentation 
-        where profiling_active = true''' 
-    if ok != []:
-        query = query + ' and categ_id not in %s'
-    query = query + ' order by id '
-
-    cr.execute(query, (tuple(ids),))
+        select id, categ_id
+        from crm_segmentation
+        where profiling_active = true'''
+    if not categories:
+        query_params = ()
+    else:
+        query += ' and categ_id not in %s'
+        query_params = (tuple(categories),)
+    query += ' order by id '
+
+    cr.execute(query, query_params)
     segm_cat_ids = cr.fetchall()
 
     for (segm_id, cat_id) in segm_cat_ids:
         if test_prof(cr, uid, segm_id, pid, answers_ids):
-            ok.append(cat_id)
-    return ok
+            categories.append(cat_id)
+    return categories
 
 
 class question(osv.osv):
index 8fd9be6..7710f09 100644 (file)
@@ -37,7 +37,7 @@ class one2many_mod_task(fields.one2many):
         for id in ids:
             res[id] = []
         for id in ids:
-            query = "select project_id from event_event where id = %i"
+            query = "select project_id from event_event where id = %s"
             cr.execute(query, (id,))
             project_ids = [ x[0] for x in cr.fetchall()]
             ids2 = obj.pool.get(self._obj).search(cr, user, [(self._fields_id,'in',project_ids),('state','<>','done')], limit=self._limit)
index 29666f4..47e2cea 100644 (file)
@@ -32,7 +32,7 @@ def _invoice_membership(self, cr, uid, data, context):
     cr.execute('''
             SELECT partner_id, id, type
             FROM res_partner_address
-            WHERE partner_id IN (%s)
+            WHERE partner_id IN %s
             ''', (tuple(partner_ids),))
     fetchal = cr.fetchall()
     if not fetchal:
index ffd063f..f9b51c9 100644 (file)
@@ -370,7 +370,7 @@ class stock_picking(osv.osv):
             sql_str = """update stock_move set
                     date_planned=%s
                 where
-                    picking_id=%d """
+                    picking_id=%s """
             sqlargs = (value, pick.id)
 
             if pick.max_date:
@@ -857,7 +857,7 @@ class stock_production_lot(osv.osv):
                 location_id in %s
             group by
                 prodlot_id
-            having sum(name) ''' + str(args[0][1]) + ' %s'
+            having sum(name) ''' + str(args[0][1]) + ' %s',
                    (tuple(locations), args[0][2]))
         res = cr.fetchall()
         ids = [('id', 'in', map(lambda x: x[0], res))]