From fe3b258debb77589a15f8b299c910ffd4dd3bdff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 3 Jul 2020 21:19:53 +0200 Subject: [PATCH] Convert unit price to company currency and default product uom issue9439 review325641002 --- stock.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/stock.py b/stock.py index d173d6c125..ea368b52c9 100644 --- a/stock.py +++ b/stock.py @@ -408,6 +408,7 @@ class ShipmentDrop(Workflow, ModelSQL, ModelView): pool = Pool() UoM = pool.get('product.uom') Move = pool.get('stock.move') + Currency = pool.get('currency.currency') to_save = [] for shipment in shipments: @@ -425,10 +426,15 @@ class ShipmentDrop(Workflow, ModelSQL, ModelView): for s_move in shipment.supplier_moves: if s_move.state == 'cancelled': continue - if s_move.cost_price: - internal_quantity = Decimal(str(s_move.internal_quantity)) - product_cost[s_move.product] += ( - s_move.unit_price * internal_quantity) + internal_quantity = Decimal(str(s_move.internal_quantity)) + with Transaction().set_context(date=s_move.effective_date): + unit_price = Currency.compute( + s_move.currency, s_move.unit_price, + s_move.company.currency, round=False) + unit_price = UoM.compute_price( + s_move.uom, unit_price, s_move.product.default_uom) + product_cost[s_move.product] += ( + unit_price * internal_quantity) quantity = UoM.compute_qty( s_move.uom, s_move.quantity, s_move.product.default_uom,