Skip to content

Commit

Permalink
[FIX] stock: programming error in average price computation for multi…
Browse files Browse the repository at this point in the history
…ple lines of the same product

While processing a picking we must keep track of
previously processed lines as they modify the
stock on hand but are not yet included in the
`qty_available` function.
Negative stock on hand is handled as if
the stock was zero as far as the average
price computation is concerned.

bzr revid: [email protected]
  • Loading branch information
odony committed Nov 4, 2013
1 parent 5f56739 commit a6ca3b0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions addons/stock/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,17 +1275,17 @@ def do_partial(self, cr, uid, ids, partial_datas, context=None):
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:
new_price = currency_obj.compute(cr, uid, product_currency,
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
Expand All @@ -1301,6 +1301,9 @@ def do_partial(self, cr, uid, ids, partial_datas, context=None):
{'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]
Expand Down

0 comments on commit a6ca3b0

Please sign in to comment.