From 39bde19663d729ce94574ca9cf85bb6c23cd9709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 29 Oct 2008 19:59:17 +0100 Subject: [PATCH] Use negative quantity to update cost price --- move.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/move.py b/move.py index e7a29cdaaa..a6ec7088cc 100644 --- a/move.py +++ b/move.py @@ -274,9 +274,6 @@ class Move(OSV): if not product.cost_price_method == 'average': return - sign = quantity > 0 and 1 or -1 - quantity = abs(quantity) - if isinstance(uom, (int, long)): uom = uom_obj.browse(cursor, user, uom, context=context) if isinstance(company, (int, long)): @@ -300,8 +297,8 @@ class Move(OSV): unit_price = uom_obj.compute_price( cursor, user, uom, unit_price, product.default_uom, context=context) new_cost_price = ( - (product.cost_price * product_qty) + (unit_price * qty * sign) - ) / (product_qty + qty * sign) + (product.cost_price * product_qty) + (unit_price * qty) + ) / (product_qty + qty) product_obj.write( cursor, user, product.id, {'cost_price': new_cost_price}, context=context)