From c6200a7ace472900cfbd9902f41d91850ef1a8e5 Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Wed, 3 Jun 2009 14:56:56 +0530 Subject: [PATCH] [FIX] Bug 382641 : _get_stock corrected bzr revid: jvo@tinyerp.com-20090603092656-3hlcehat8ua8ojd2 --- addons/stock/stock.py | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index dd5f0a89fc9..a95234a7c61 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -785,20 +785,26 @@ class stock_production_lot(osv.osv): if 'location_id' not in context: locations = self.pool.get('stock.location').search(cr, uid, [('usage','=','internal')], context=context) else: - locations = [context['location_id']] + locations = context['location_id'] and [context['location_id']] or [] + + if isinstance(ids, (int, long)): + ids = [ids] + res = {}.fromkeys(ids, 0.0) - cr.execute('''select - prodlot_id, - sum(name) - from - stock_report_prodlots - where - location_id in ('''+','.join(map(str, locations))+''') and - prodlot_id in ('''+','.join(map(str, ids))+''') - group by - prodlot_id - ''') - res.update(dict(cr.fetchall())) + + if locations: + cr.execute('''select + prodlot_id, + sum(name) + from + stock_report_prodlots + where + location_id in ('''+','.join(map(str, locations))+''') and + prodlot_id in ('''+','.join(map(str, ids))+''') + group by + prodlot_id + ''') + res.update(dict(cr.fetchall())) return res def _stock_search(self, cr, uid, obj, name, args):