Add unit_price_company Function field on stock move

issue9401
review290341002
This commit is contained in:
Cédric Krier
2020-07-04 00:21:39 +02:00
parent 452550c92f
commit ed54edae30
2 changed files with 4 additions and 10 deletions
+3 -4
View File
@@ -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)
+1 -6
View File
@@ -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))