changeset d58df28746b4 in modules/web_shop:6.2
details: https://hg.tryton.org/modules/web_shop?cmd=changeset&node=d58df28746b4
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
        review419361003
        (grafted from b31d8703761f6bbf07f4d0116cb949f8f0033b90)
diffstat:

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

diffs (28 lines):

diff -r 5a9912b329b0 -r d58df28746b4 web.py
--- a/web.py    Sat Jul 09 23:15:20 2022 +0200
+++ b/web.py    Sun Jul 17 00:00:56 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