From 340d5f58398a44e620b28626deeca574d58d26d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 22 Oct 2015 18:14:45 +0200 Subject: [PATCH] Missing conversion of unit price to company currency The currency of unit price on move is defined by the currency field. So to compute the cost price, it should first be converted to the company currency. issue5057 review19561002 --- move.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/move.py b/move.py index 08b3b8f571..8ae79181a5 100644 --- a/move.py +++ b/move.py @@ -3,6 +3,7 @@ from decimal import Decimal from trytond.model import Workflow, ModelView, fields, Check from trytond.pool import Pool, PoolMeta +from trytond.transaction import Transaction __all__ = ['Move'] __metaclass__ = PoolMeta @@ -36,8 +37,9 @@ class Move: fifo_quantity on the concerned incomming moves. Return the cost price for outputing the given product and quantity. ''' - - Uom = Pool().get('product.uom') + pool = Pool() + Uom = pool.get('product.uom') + Currency = pool.get('currency.currency') total_qty = Uom.compute_qty(self.uom, self.quantity, self.product.default_uom, round=False) @@ -49,7 +51,11 @@ class Move: for move, move_qty in fifo_moves: consumed_qty += move_qty - move_unit_price = Uom.compute_price(move.uom, move.unit_price, + with Transaction().set_context(date=move.effective_date): + move_unit_price = Currency.compute( + move.currency, move.unit_price, + self.company.currency, round=False) + move_unit_price = Uom.compute_price(move.uom, move_unit_price, move.product.default_uom) cost_price += move_unit_price * Decimal(str(move_qty))