[FIX] stock: properly pass production lot number as SQL query parameter
authorOlivier Dony <odo@openerp.com>
Mon, 18 Jun 2012 17:42:54 +0000 (19:42 +0200)
committerOlivier Dony <odo@openerp.com>
Mon, 18 Jun 2012 17:42:54 +0000 (19:42 +0200)
lp bug: https://launchpad.net/bugs/1014759 fixed

bzr revid: odo@openerp.com-20120618174254-nb73b0a6wt6nzot0

addons/stock/product.py

index c63522b..5fe9047 100644 (file)
@@ -255,6 +255,10 @@ class product_product(osv.osv):
             date_values = [to_date]
 
         prodlot_id = context.get('prodlot_id', False)
+        prodlot_clause = ''
+        if prodlot_id:
+            prodlot_clause = ' and prodlot_id = %s '
+            where += [prodlot_id]
 
     # TODO: perhaps merge in one query.
         if date_values:
@@ -267,8 +271,8 @@ class product_product(osv.osv):
                 'where location_id NOT IN %s '\
                 'and location_dest_id IN %s '\
                 'and product_id IN %s '\
-                '' + (prodlot_id and ('and prodlot_id = ' + str(prodlot_id)) or '') + ' '\
                 'and state IN %s ' + (date_str and 'and '+date_str+' ' or '') +' '\
+                + prodlot_clause + 
                 'group by product_id,product_uom',tuple(where))
             results = cr.fetchall()
         if 'out' in what:
@@ -279,8 +283,8 @@ class product_product(osv.osv):
                 'where location_id IN %s '\
                 'and location_dest_id NOT IN %s '\
                 'and product_id  IN %s '\
-                '' + (prodlot_id and ('and prodlot_id = ' + str(prodlot_id)) or '') + ' '\
                 'and state in %s ' + (date_str and 'and '+date_str+' ' or '') + ' '\
+                + prodlot_clause + 
                 'group by product_id,product_uom',tuple(where))
             results2 = cr.fetchall()
         uom_obj = self.pool.get('product.uom')