From b1f8aa98da905cef5bbb9c3ccc63cede1165e1a7 Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Wed, 8 Dec 2010 15:02:58 +0530 Subject: [PATCH] [FIX]: stock: Source location and destination location should be considered separately while finding stock.move in order to compute proper value of product when we have only one move lp bug: https://launchpad.net/bugs/683718 fixed bzr revid: rpa@tinyerp.com-20101208093258-qih3i1yj19hi7atv --- addons/stock/stock.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 6723c1b142b..7ae3941c545 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -114,8 +114,11 @@ class stock_location(osv.osv): product_product_obj = self.pool.get('product.product') - cr.execute('select distinct product_id, location_id from stock_move where location_id in %s or location_dest_id in %s', (tuple(ids), tuple(ids))) - res_products_by_location = sorted(cr.dictfetchall(), key=itemgetter('location_id')) + cr.execute('select distinct product_id, location_id from stock_move where location_id in %s', (tuple(ids), )) + dict1 = cr.dictfetchall() + cr.execute('select distinct product_id, location_dest_id as location_id from stock_move where location_dest_id in %s', (tuple(ids), )) + dict2 = cr.dictfetchall() + res_products_by_location = sorted(dict1+dict2, key=itemgetter('location_id')) products_by_location = dict((k, [v['product_id'] for v in itr]) for k, itr in groupby(res_products_by_location, itemgetter('location_id'))) result = dict([(i, {}.fromkeys(field_names, 0.0)) for i in ids])