[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
This commit is contained in:
Nicolas Martinelli 2017-02-01 11:52:44 +01:00
parent c5bda97494
commit e0222de3c2
1 changed files with 1 additions and 1 deletions

View File

@ -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 } }