From 1f0b7547850baf0fc5ba453d025ddfd8efc5895b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 26 Dec 2024 16:12:10 +0100 Subject: [PATCH] Fill production moves with all default values When used for on_change, we need to fill all the default values as the client does create new record with default values. Closes #12575 --- modules/production/production.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/production/production.py b/modules/production/production.py index d64cd7a836..b980e5327b 100644 --- a/modules/production/production.py +++ b/modules/production/production.py @@ -368,12 +368,11 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): pool = Pool() Move = pool.get('stock.move') assert type in {'input', 'output'} - move = Move( - product=product, - unit=unit, - quantity=quantity, - company=self.company, - state=Move.default_state()) + move = Move(**Move.default_get(with_rec_name=False)) + move.product = product + move.unit = unit + move.quantity = quantity + move.company = self.company if type == 'input': move.from_location = self.picking_location move.to_location = self.location @@ -387,6 +386,9 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): move.unit_price = Decimal(0) if self.company: move.currency = self.company.currency + else: + move.unit_price = None + move.currency = None return move @fields.depends(