From b1b9cb591c54c18f75097649c6aa9873cfdbd33c Mon Sep 17 00:00:00 2001
From: Christophe Simonis <christophe@tinyerp.com>
Date: Mon, 9 Feb 2009 15:16:46 +0100
Subject: [PATCH] [FIX] query

lp bug: https://launchpad.net/bugs/327120 fixed

bzr revid: christophe@tinyerp.com-20090209141646-0x02see4flirq8zj
---
 .../wizard/hr_timesheet_invoice_create.py             | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py
index fd5201b62bc8..0d2c7120503f 100644
--- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py
+++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py
@@ -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:
-- 
GitLab