changeset cc5b530e667e in modules/purchase:6.0
details: https://hg.tryton.org/modules/purchase?cmd=changeset&node=cc5b530e667e
description:
        Ensure unique taxes when applying tax rule

        Since issue10841 the taxes must be unique so the tax rule application 
must
        result on unique taxes.

        issue11230
        review415271003
diffstat:

 purchase.py |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (29 lines):

diff -r 3d44841e25c5 -r cc5b530e667e purchase.py
--- a/purchase.py       Fri Jun 03 19:21:29 2022 +0200
+++ b/purchase.py       Sun Jul 17 00:02:22 2022 +0200
@@ -1332,20 +1332,20 @@
 
     @fields.depends('product', methods=['_get_tax_rule_pattern'])
     def compute_taxes(self, party):
-        taxes = []
+        taxes = set()
         pattern = self._get_tax_rule_pattern()
         for tax in self.product.supplier_taxes_used:
             if party and party.supplier_tax_rule:
                 tax_ids = party.supplier_tax_rule.apply(tax, pattern)
                 if tax_ids:
-                    taxes.extend(tax_ids)
+                    taxes.update(tax_ids)
                 continue
-            taxes.append(tax.id)
+            taxes.add(tax.id)
         if party and party.supplier_tax_rule:
             tax_ids = party.supplier_tax_rule.apply(None, pattern)
             if tax_ids:
-                taxes.extend(tax_ids)
-        return taxes
+                taxes.update(tax_ids)
+        return list(taxes)
 
     @fields.depends('product', 'quantity',
         methods=['_get_context_purchase_price'])

Reply via email to