From e0222de3c2210c9bd6d67ad1e4f90f44a86938ba Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 1 Feb 2017 11:52:44 +0100 Subject: [PATCH] [FIX] stock: update qty on hand When the quantity on hand is updated from the wizard, it may result in completely inconsistent results. This happens for example in the following case: - 10 Units in Stock/WH - 18 Units in Stock/WH/Shelf 1 The "New Quantity on Hand" suggests a theoretical quantity by taking into account the location and its sub-locations. It the example, that would mean 28 Units in location 'Stock/WH'. However, the `_get_quants` method of the `stock.inventory.line` model doesn't take into account the children locations. Therefore, the theoretical quantity would be 10 Units in location 'Stock/WH'. This inconsistency confuses the user, and the new quantity added might introduce unexpected results. opw-703886 --- addons/stock/wizard/stock_change_product_qty.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/wizard/stock_change_product_qty.py b/addons/stock/wizard/stock_change_product_qty.py index 98834d16882..0606ffe02c7 100644 --- a/addons/stock/wizard/stock_change_product_qty.py +++ b/addons/stock/wizard/stock_change_product_qty.py @@ -131,7 +131,7 @@ class stock_change_product_qty(osv.osv_memory): def onchange_location_id(self, cr, uid, ids, location_id, product_id, context=None): if location_id: qty_wh = 0.0 - qty = self.pool.get('product.product')._product_available(cr, uid, [product_id], context=dict(context or {}, location=location_id)) + qty = self.pool.get('product.product')._product_available(cr, uid, [product_id], context=dict(context or {}, location=location_id, compute_child=False)) if product_id in qty: qty_wh = qty[product_id]['qty_available'] return { 'value': { 'new_quantity': qty_wh } }