[FIX] account: fix traceback on credit note after editing Group of Taxes

- Go to Accounting > Configuration > Taxes and create a new Group of Taxes:
  * Tax Name: TaxGroup
  * Tax Computation: Group of Taxes
  * Add 2 taxes (i.e. T1 15% and T2 20%)
- Go to Accounting > Customers > Invoices and create a new Invoice:
  * Add a Product and select TaxGroup as Taxes
- Post the invoice
- Go to TaxGroup edition and remove T2 20%
- Go back to create Invoice and add a Credit Note
At Credit Note creation, a KeyError is triggered.

opw-2321199

closes odoo/odoo#56729

X-original-commit: 816c0fa0f74d6126aecd663183361e53a1d8b460
Signed-off-by: Anh Thao PHAM <kitan191@users.noreply.github.com>
This commit is contained in:
Anh Thao Pham (pta)
2020-08-28 11:58:51 +00:00
parent 94426e0ee2
commit 12e0e6092d
2 changed files with 10 additions and 0 deletions
+8
View File
@@ -6071,6 +6071,14 @@ msgid ""
"entry again and cancel it thanks to a regular revert."
msgstr ""
#. module: account
#: code:addons/account/models/account_move.py:0
#, python-format
msgid ""
"It seems that the taxes have been modified since the creation of the journal"
" entry. You should create the credit note manually instead."
msgstr ""
#. module: account
#: model_terms:ir.ui.view,arch_db:account.view_move_form
msgid "JRNL/2016/00001"
+2
View File
@@ -2121,6 +2121,8 @@ class AccountMove(models.Model):
elif line_vals.get('tax_repartition_line_id'):
# Tax line.
invoice_repartition_line = self.env['account.tax.repartition.line'].browse(line_vals['tax_repartition_line_id'])
if invoice_repartition_line not in tax_repartition_lines_mapping:
raise UserError(_("It seems that the taxes have been modified since the creation of the journal entry. You should create the credit note manually instead."))
refund_repartition_line = tax_repartition_lines_mapping[invoice_repartition_line]
# Find the right account.