From a84cb9f07c51f649f5ff2a2ae94e1904e210c7f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 8 Apr 2023 16:36:38 +0200 Subject: [PATCH] Do not change account nor journal of invoice no more draft Closes #12146 --- modules/account_invoice/invoice.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/account_invoice/invoice.py b/modules/account_invoice/invoice.py index b54083bcf2..a8714011b1 100644 --- a/modules/account_invoice/invoice.py +++ b/modules/account_invoice/invoice.py @@ -486,8 +486,11 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin): def on_change_with_company_party(self, name=None): return self.company.party if self.company else None - @fields.depends('party', 'type', 'accounting_date', 'invoice_date') + @fields.depends( + 'state', 'account', 'party', 'type', 'accounting_date', 'invoice_date') def on_change_with_account(self): + if self.state != 'draft': + return self.account account = None if self.party: with Transaction().set_context( @@ -505,10 +508,12 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin): else: return ['expense'] - @fields.depends('type') + @fields.depends('state', 'journal', 'type') def on_change_with_journal(self, pattern=None): pool = Pool() Journal = pool.get('account.journal') + if self.state != 'draft': + return self.journal pattern = pattern.copy() if pattern is not None else {} pattern.setdefault('type', { 'out': 'revenue',