From 667d8bfcf290f527d2fc4783b8708cb9b9815218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 17 Jul 2022 00:00:56 +0200 Subject: [PATCH] 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 --- stock.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/stock.py b/stock.py index 12140f8c68..3db62ae854 100644 --- a/stock.py +++ b/stock.py @@ -186,19 +186,19 @@ class Move(metaclass=PoolMeta): 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( @@ -231,19 +231,19 @@ class Move(metaclass=PoolMeta): 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(