[FIX] account, l10n_in: amount by group base when overriden

Fine tuning of 7bea912
In india there are as many tax lines on an invoices as there are
repartition lines (classic) * products

So, before this commit, preventing adding the base if tax was already seen
was not enough, the base was still added many times

After this commit, hopefully, the based on amount is correct for each tax

Forward port of #37390

closes odoo/odoo#37784

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
Lucas Perais (lpe)
2019-10-02 13:00:58 +00:00
parent 7d93c80693
commit e47e74afc4
2 changed files with 21 additions and 2 deletions
+12 -2
View File
@@ -1240,10 +1240,11 @@ class AccountMove(models.Model):
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
if line.tax_line_id.id not in done_taxes:
tax_key_add_base = tuple(move._get_tax_key_for_group_add_base(line))
if tax_key_add_base not in done_taxes:
# The base should be added ONCE
res[line.tax_line_id.tax_group_id]['base'] += line.tax_base_amount
done_taxes.add(line.tax_line_id.id)
done_taxes.add(tax_key_add_base)
res = sorted(res.items(), key=lambda l: l[0].sequence)
move.amount_by_group = [(
group.name, amounts['amount'],
@@ -1254,6 +1255,15 @@ class AccountMove(models.Model):
group.id
) for group, amounts in res]
@api.model
def _get_tax_key_for_group_add_base(self, line):
"""
Useful for _compute_invoice_taxes_by_group
must be consistent with _get_tax_grouping_key_from_tax_line
@return list
"""
return [line.tax_line_id.id]
@api.depends('date', 'line_ids.debit', 'line_ids.credit', 'line_ids.tax_line_id', 'line_ids.tax_ids', 'line_ids.tag_ids')
def _compute_tax_lock_date_message(self):
for move in self:
+9
View File
@@ -46,3 +46,12 @@ class AccountMove(models.Model):
'quantity': base_line.quantity,
})
return res
@api.model
def _get_tax_key_for_group_add_base(self, line):
tax_key = super(AccountMove, self)._get_tax_key_for_group_add_base(line)
tax_key += [
line.product_id.id,
]
return tax_key