From 691a22f808d8467e59a22a7edb692a53aa97e8a6 Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Tue, 31 Dec 2019 06:20:27 +0000 Subject: [PATCH] [FIX] account: avoid base being included twice in group Create multiple tax and assign them to the same tax group. Now create an invoice, in the line add all the taxes in the group. Save and click on "Preview". In the tax recap the tax group will be reported applied on a total equal to the number of used taxes multiplied by the total of the product. This append because in the calculation the tax are included multiple times and not just once per group. opw-2158989 closes odoo/odoo#42814 X-original-commit: 261c528b87bd8e5b5e4cd0dbaf01c49197bf192c Signed-off-by: Nicolas Martinelli (nim) --- addons/account/models/account_move.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 73185c68ad4..dec90a77767 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1267,11 +1267,12 @@ class AccountMove(models.Model): res = {} # There are as many tax line as there are repartition lines done_taxes = set() + done_groups = set() for line in tax_lines: res.setdefault(line.tax_line_id.tax_group_id, {'base': 0.0, 'amount': 0.0}) res[line.tax_line_id.tax_group_id]['amount'] += line.price_subtotal tax_key_add_base = tuple(move._get_tax_key_for_group_add_base(line)) - if tax_key_add_base not in done_taxes: + if tax_key_add_base not in done_taxes and line.tax_line_id.tax_group_id not in done_groups: if line.currency_id != self.company_id.currency_id: amount = self.company_id.currency_id._convert(line.tax_base_amount, line.currency_id, self.company_id, line.date) else: @@ -1279,6 +1280,7 @@ class AccountMove(models.Model): res[line.tax_line_id.tax_group_id]['base'] += amount # The base should be added ONCE done_taxes.add(tax_key_add_base) + done_groups.add(line.tax_line_id.tax_group_id) res = sorted(res.items(), key=lambda l: l[0].sequence) move.amount_by_group = [( group.name, amounts['amount'],