diff --git a/addons/account/models/account.py b/addons/account/models/account.py index 47f4021504d..d0aca4fafe4 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -602,6 +602,11 @@ class AccountTax(models.Model): if self.price_include: self.include_base_amount = True + def get_grouping_key(self, invoice_tax_val): + """ Returns a string that will be used to group account.invoice.tax sharing the same properties""" + self.ensure_one() + return str(invoice_tax_val['tax_id']) + '-' + str(invoice_tax_val['account_id']) + '-' + str(invoice_tax_val['account_analytic_id']) + def _compute_amount(self, base_amount, price_unit, quantity=1.0, product=None, partner=None): """ Returns the amount of a single tax. base_amount is the actual amount on which the tax is applied, which is price_unit * quantity eventually affected by previous taxes (if tax is include_base_amount XOR price_include) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 3ac033834f8..8c0f643bc6f 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -567,7 +567,8 @@ class AccountInvoice(models.Model): if not val.get('account_analytic_id') and line.account_analytic_id and val['account_id'] == line.account_id.id: val['account_analytic_id'] = line.account_analytic_id.id - key = str(tax['id']) + '-' + str(val['account_id']) + key = self.env['account.tax'].browse(tax['id']).get_grouping_key(val) + if key not in tax_grouped: tax_grouped[key] = val else: