From c5aadfb64a278a69eb3ba05e23be579151b84edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 5 Apr 2025 19:43:09 +0200 Subject: [PATCH] Clear currency on output move of production to lost and found --- modules/production/stock.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/modules/production/stock.py b/modules/production/stock.py index d2327647cf..bc0a272aca 100644 --- a/modules/production/stock.py +++ b/modules/production/stock.py @@ -90,10 +90,27 @@ class Move(metaclass=PoolMeta): 'production.msg_stock_move_production_single'), ] - @fields.depends('production_output', '_parent_production_output.company') + @fields.depends( + 'production_output', '_parent_production_output.company', + 'to_location') def on_change_production_output(self): - if self.production_output and self.production_output.company: - self.currency = self.production_output.company.currency + if self.production_output: + if self.production_output.company: + self.currency = self.production_output.company.currency + if self.to_location and self.to_location.type == 'lost_found': + self.currency = None + + @fields.depends( + 'production_output', '_parent_production_output.id', 'to_location') + def on_change_to_location(self): + try: + super().on_change_to_location() + except AttributeError: + pass + if (self.production_output + and self.to_location + and self.to_location.type == 'lost_found'): + self.currency = None @fields.depends( 'production_input', '_parent_production_input.id',