Cédric Krier pushed to branch branch/default at Tryton / Tryton


Commits:
73697963 by Cédric Krier at 2023-04-08T16:36:38+02:00
Do not change account nor journal of invoice no more draft

Closes #12146
- - - - -


1 changed file:

- modules/account_invoice/invoice.py


Changes:

=====================================
modules/account_invoice/invoice.py
=====================================
@@ -486,5 +486,6 @@
     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):
@@ -490,4 +491,6 @@
     def on_change_with_account(self):
+        if self.state != 'draft':
+            return self.account
         account = None
         if self.party:
             with Transaction().set_context(
@@ -505,7 +508,7 @@
         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')
@@ -509,6 +512,8 @@
     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',



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/73697963ab5783d8dfe531d0997ac58e48d19994

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/73697963ab5783d8dfe531d0997ac58e48d19994
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to