From 5feb1fd1e1a9c7fb91aece5685ae166c1f10bac6 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 9 Sep 2010 14:46:41 +0200 Subject: [PATCH] [IMP] stock inventory: don't count products recursively when computing the delta bzr revid: odo@openerp.com-20100909124641-5jv31k8nqji8c2xu --- addons/stock/stock.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 2294da261d8..5f1aab239d6 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2344,14 +2344,19 @@ class stock_inventory(osv.osv): """ if context is None: context = {} + + # to perform the correct inventory corrections we need analyze stock location by + # location, never recursively, so we use a special context + product_context = dict(context, compute_child=False) + + location_obj = self.pool.get('stock.location') for inv in self.browse(cr, uid, ids): move_ids = [] move_line = [] for line in inv.inventory_line_id: pid = line.product_id.id - - amount = self.pool.get('stock.location')._product_get(cr, uid, line.location_id.id, [pid], {'uom': line.product_uom.id})[pid] - #TOCHECK: Why put restriction like new inventory qty should greater available qty ? + product_context.update(uom=line.product_uom.id) + amount = location_obj._product_get(cr, uid, line.location_id.id, [pid], product_context)[pid] change = line.product_qty - amount lot_id = line.prod_lot_id.id if change: