From b59deb4743a40f45ca7fefe57e24a3b21072327b Mon Sep 17 00:00:00 2001 From: "rha@tinyerp.com" <> Date: Wed, 5 Jan 2011 15:18:05 +0530 Subject: [PATCH] [Fix] Stock: wizard_partial_picking Average price computation doesnt work as expected lp bug: https://launchpad.net/bugs/688493 fixed bzr revid: rha@tinyerp.com-20110105094805-81s66oet81tgtfqf --- addons/stock/stock.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 97d5f9a0270..eede42d3d70 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1169,6 +1169,7 @@ class stock_picking(osv.osv): complete, too_many, too_few = [], [], [] move_product_qty = {} prodlot_ids = {} + product_avail = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue @@ -1194,6 +1195,12 @@ class stock_picking(osv.osv): move_currency_id = move.company_id.currency_id.id 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: + product_avail[product.id] = product.qty_available + if qty > 0: new_price = currency_obj.compute(cr, uid, product_currency, move_currency_id, product_price) @@ -1204,9 +1211,8 @@ class stock_picking(osv.osv): else: # Get the standard price amount_unit = product.price_get('standard_price', context)[product.id] - new_std_price = ((amount_unit * product.qty_available)\ - + (new_price * qty))/(product.qty_available + qty) - + new_std_price = ((amount_unit * product_avail[product.id])\ + + (new_price * qty))/(product_avail[product.id] + qty) # Write the field according to price type field product_obj.write(cr, uid, [product.id], {'standard_price': new_std_price})