changeset 2f7565adb5d1 in modules/stock_consignment:6.0
details: 
https://hg.tryton.org/modules/stock_consignment?cmd=changeset&node=2f7565adb5d1
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:

 stock.py |  16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diffs (51 lines):

diff -r c6a94e2ba89e -r 2f7565adb5d1 stock.py
--- a/stock.py  Mon May 03 16:06:22 2021 +0200
+++ b/stock.py  Sun Jul 17 00:02:22 2022 +0200
@@ -188,19 +188,19 @@
         line.stock_moves = [self]
         line.origin = self
 
-        taxes = []
+        taxes = set()
         pattern = self._get_tax_rule_pattern()
         for tax in line.product.supplier_taxes_used:
             if line.party.supplier_tax_rule:
                 tax_ids = line.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 line.party.supplier_tax_rule:
             tax_ids = line.party.supplier_tax_rule.apply(None, pattern)
             if tax_ids:
-                taxes.extend(tax_ids)
+                taxes.update(tax_ids)
         line.taxes = taxes
 
         with Transaction().set_context(
@@ -232,19 +232,19 @@
         line.stock_moves = [self]
         line.origin = self
 
-        taxes = []
+        taxes = set()
         pattern = self._get_tax_rule_pattern()
         for tax in line.product.customer_taxes_used:
             if line.party.customer_tax_rule:
                 tax_ids = line.party.customer_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 line.party.customer_tax_rule:
             tax_ids = line.party.customer_tax_rule.apply(None, pattern)
             if tax_ids:
-                taxes.extend(tax_ids)
+                taxes.update(tax_ids)
         line.taxes = taxes
 
         with Transaction().set_context(

Reply via email to