From ed54edae3041b7f28d3f980da30045fa2a2a985a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 4 Jul 2020 00:21:39 +0200 Subject: [PATCH] Add unit_price_company Function field on stock move issue9401 review290341002 --- move.py | 7 +++---- product.py | 7 +------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/move.py b/move.py index 0d42b28821..e77ff1db73 100644 --- a/move.py +++ b/move.py @@ -107,11 +107,10 @@ class Move(metaclass=PoolMeta): 'cost_price', **self._cost_price_pattern) # Compute average cost price - unit_price = self.unit_price - self.unit_price = Uom.compute_price( - self.product.default_uom, cost_price, self.uom) + self.unit_price_company, unit_price_company = ( + cost_price, self.unit_price_company) average_cost_price = self._compute_product_cost_price('out') - self.unit_price = unit_price + self.unit_price_company = unit_price_company if cost_price: cost_price = round_price(cost_price) diff --git a/product.py b/product.py index 8afd781b2e..49a3b59bc6 100644 --- a/product.py +++ b/product.py @@ -152,12 +152,7 @@ class Product(metaclass=PoolMeta): for move, move_qty in fifo_moves: consumed_qty += move_qty if move.from_location.type in {'supplier', 'production'}: - with Transaction().set_context(date=move.effective_date): - unit_price = Currency.compute( - move.currency, move.unit_price, - move.company.currency, round=False) - unit_price = Uom.compute_price( - move.uom, unit_price, move.product.default_uom) + unit_price = move.unit_price_company else: unit_price = move.cost_price or 0 cost_price += unit_price * Decimal(str(move_qty))