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()