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

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

diffs (28 lines):

diff -r b155b272d0cc -r 88341b1ac454 web.py
--- a/web.py    Wed Sep 01 22:53:16 2021 +0200
+++ b/web.py    Sun Jul 17 00:02:22 2022 +0200
@@ -193,19 +193,19 @@
         customer_tax_rule = self._customer_taxe_rule()
         taxes2products = defaultdict(list)
         for product in all_products:
-            taxes = []
+            taxes = set()
             for tax in product.customer_taxes_used:
                 if customer_tax_rule:
                     tax_ids = 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 customer_tax_rule:
                 tax_ids = customer_tax_rule.apply(None, pattern)
                 if tax_ids:
-                    taxes.extend(tax_ids)
-            taxes2products[tuple(taxes)].append(product)
+                    taxes.update(tax_ids)
+            taxes2products[tuple(sorted(taxes))].append(product)
 
         prices, taxes = {}, {}
         for tax_ids, products in taxes2products.items():

Reply via email to