From acc0a0a4c2701b19fc3bc35dfd5e74863e1d523a Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 18 Jun 2012 19:41:53 +0200 Subject: [PATCH] [FIX] stock: properly pass production lot number as SQL query parameter lp bug: https://launchpad.net/bugs/1014759 fixed bzr revid: odo@openerp.com-20120618174153-kx2hcqv2wq7bhf3c --- addons/stock/product.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/stock/product.py b/addons/stock/product.py index 304fa8dcd87..09a73852e82 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -250,6 +250,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: @@ -262,8 +266,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: @@ -274,8 +278,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()