[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
This commit is contained in:
rpa (Open ERP) 2010-12-08 15:02:58 +05:30
parent f66cb36682
commit b1f8aa98da
1 changed files with 5 additions and 2 deletions

View File

@ -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])