summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2019-10-02 12:54:24 +0000
committerLucas Perais (lpe) <lpe@odoo.com>2019-10-02 13:00:58 +0000
commite47e74afc4cf649be9a476785b0dc375c92aea2a (patch)
tree5ab87893ad187f2bb6cd2b2fa966ebfaeea243e0
parent7d93c80693574cfd7baf9a2dc54283ac4ae8cb5b (diff)
[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>
-rw-r--r--addons/account/models/account_move.py14
-rw-r--r--addons/l10n_in/models/account_invoice.py9
2 files changed, 21 insertions, 2 deletions
diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py
index cbaa5306e87..b438bd555ad 100644
--- a/addons/account/models/account_move.py
+++ b/addons/account/models/account_move.py
@@ -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:
diff --git a/addons/l10n_in/models/account_invoice.py b/addons/l10n_in/models/account_invoice.py
index 69ff5cb7842..b960b47c791 100644
--- a/addons/l10n_in/models/account_invoice.py
+++ b/addons/l10n_in/models/account_invoice.py
@@ -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