diff --git a/addons/stock/stock.py b/addons/stock/stock.py index fb595d76cc1..d65689ede43 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1275,9 +1275,8 @@ class stock_picking(osv.osv): context['currency_id'] = move_currency_id qty = uom_obj._compute_qty(cr, uid, product_uom, product_qty, product.uom_id.id) - if product.id in product_avail: - product_avail[product.id] += qty - else: + if product.id not in product_avail: + # keep track of stock on hand including processed lines not yet marked as done product_avail[product.id] = product.qty_available if qty > 0: @@ -1285,7 +1284,8 @@ class stock_picking(osv.osv): move_currency_id, product_price) new_price = uom_obj._compute_price(cr, uid, product_uom, new_price, product.uom_id.id) - if product.qty_available <= 0: + if product_avail[product.id] <= 0: + product_avail[product.id] = 0 new_std_price = new_price else: # Get the standard price @@ -1301,6 +1301,9 @@ class stock_picking(osv.osv): {'price_unit': product_price, 'price_currency_id': product_currency}) + product_avail[product.id] += qty + + for move in too_few: product_qty = move_product_qty[move.id]