From eae581d717066a7eba836a9d550caf9ebcbd43e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 25 Mar 2013 19:30:02 +0100 Subject: [PATCH] Fix missing unit_price currency convertion issue3072 review731002 (transplanted from acd9a30f1c147a7c8637201c6b829ef1dd67b21a) --- stock.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/stock.py b/stock.py index 3cb8fb7211..f99ab8fa2f 100644 --- a/stock.py +++ b/stock.py @@ -98,7 +98,9 @@ class Move: Return the cost for quantity based on lines. Update anglo_saxon_quantity on the concerned moves. ''' - Uom = Pool().get('product.uom') + pool = Pool() + Uom = pool.get('product.uom') + Currency = pool.get('currency.currency') for move in moves: assert move.product == product, 'wrong product' @@ -114,8 +116,11 @@ class Move: consumed_qty += move_qty if type_.startswith('in_'): + with Transaction().set_context(date=move.effective_date): + unit_price = Currency.compute(move.currency, + move.unit_price, move.company.currency, round=False) move_cost_price = Uom.compute_price(move.uom, - move.unit_price, move.product.default_uom) + unit_price, move.product.default_uom) else: move_cost_price = move.cost_price cost += move_cost_price * Decimal(str(move_qty))