[FIX] query
authorChristophe Simonis <christophe@tinyerp.com>
Mon, 9 Feb 2009 14:16:46 +0000 (15:16 +0100)
committerChristophe Simonis <christophe@tinyerp.com>
Mon, 9 Feb 2009 14:16:46 +0000 (15:16 +0100)
lp bug: https://launchpad.net/bugs/327120 fixed

bzr revid: christophe@tinyerp.com-20090209141646-0x02see4flirq8zj

addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py

index fd5201b..0d2c712 100644 (file)
@@ -128,10 +128,13 @@ class invoice_create(wizard.interface):
                 #
                 # Compute for lines
                 #
-                str_ids=""
-                for x in data['ids']:
-                    str_ids += ','.join(str(x)) 
-                cr.execute("SELECT * FROM account_analytic_line WHERE account_id = %s and id IN (%s) AND product_id=%s and to_invoice=%s", (account.id, str_ids, product_id, factor_id))
+                cr.execute("SELECT * "  # TODO optimize this
+                           "  FROM account_analytic_line" 
+                           " WHERE account_id=%%s"
+                           "   AND id IN (%s)"
+                           "   AND product_id=%%s"
+                           "   AND to_invoice=%%s" % ','.join(['%s']*len(data['ids'])), 
+                           (account.id, data['ids'], product_id, factor_id))
                 line_ids = cr.dictfetchall()
                 note = []
                 for line in line_ids: