changeset c06071662b82 in modules/account_invoice:default
details: 
https://hg.tryton.org/modules/account_invoice?cmd=changeset&node=c06071662b82
description:
        Prevent using the same account on tax than invoice

        The total computation relies on the invoice account to be only used for 
the
        term lines.

        issue11151
        review366571002
diffstat:

 invoice.py |  14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diffs (24 lines):

diff -r 8e9d429ef1b5 -r c06071662b82 invoice.py
--- a/invoice.py        Wed Jan 26 00:32:20 2022 +0100
+++ b/invoice.py        Sun Jan 30 01:19:23 2022 +0100
@@ -2730,6 +2730,20 @@
                         invoice=invoice.rec_name))
         return super(InvoiceTax, cls).create(vlist)
 
+    @classmethod
+    def validate(cls, taxes):
+        super().validate(taxes)
+        for tax in taxes:
+            tax.check_same_account()
+
+    def check_same_account(self):
+        if self.account == self.invoice.account:
+            raise InvoiceTaxValidationError(
+                gettext('account_invoice.msg_invoice_same_account_line',
+                    account=self.account.rec_name,
+                    invoice=self.invoice.rec_name,
+                    line=self.rec_name))
+
     def get_move_lines(self):
         '''
         Return a list of move lines instances for invoice tax

Reply via email to