From fe4cec21899741c505c7cc8d2c79a82f84e6e3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 16 Mar 2024 21:03:13 +0100 Subject: [PATCH] Set currency and unit price of production move when unit price is required Since 0b2e50445415 the unit price is always set when production is done, so the unit price of output moves is not important before. --- modules/production/production.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/modules/production/production.py b/modules/production/production.py index 16d8e48c8f..ea135bce60 100644 --- a/modules/production/production.py +++ b/modules/production/production.py @@ -370,8 +370,7 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): product=product, unit=unit, quantity=quantity, - company=self.company, - currency=self.company.currency if self.company else None) + company=self.company) if type == 'input': move.from_location = self.picking_location move.to_location = self.location @@ -380,16 +379,18 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): move.from_location = self.location move.to_location = self.output_location move.production_output = self + if move.on_change_with_unit_price_required(): + move.unit_price = Decimal(0) + if self.company: + move.currency = self.company.currency return move @fields.depends(methods=['_move']) def _explode_move_values(self, type, bom_io, quantity): - move = self._move(type, bom_io.product, bom_io.unit, quantity) - move.unit_price_required = move.on_change_with_unit_price_required() - return move + return self._move(type, bom_io.product, bom_io.unit, quantity) @fields.depends( - 'bom', 'product', 'unit', 'quantity', 'company', 'inputs', 'outputs', + 'bom', 'product', 'unit', 'quantity', 'inputs', 'outputs', methods=['_explode_move_values']) def explode_bom(self): pool = Pool() @@ -415,8 +416,6 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): quantity = output.compute_quantity(factor) move = self._explode_move_values('output', output, quantity) if move: - move.unit_price = Decimal(0) - move.currency = self.company.currency outputs.append(move) self.outputs = outputs @@ -502,8 +501,6 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): 'output', production.product, production.unit, production.quantity) if move: - move.unit_price = Decimal(0) - move.currency = production.company.currency to_save.append(move) continue @@ -523,8 +520,6 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): move = production._move( 'output', product, output.unit, quantity) if move: - move.unit_price = Decimal(0) - move.currency = production.company.currency to_save.append(move) Move.save(to_save) cls._set_move_planned_date(productions)