From 12e0e6092d51b5691852e7041ef3085f867ddafc Mon Sep 17 00:00:00 2001 From: "Anh Thao Pham (pta)" Date: Wed, 26 Aug 2020 10:30:40 +0000 Subject: [PATCH] [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 --- addons/account/i18n/account.pot | 8 ++++++++ addons/account/models/account_move.py | 2 ++ 2 files changed, 10 insertions(+) diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index c3de090c92f..560a049aeab 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -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" diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 13ca6ebd4b5..c66f9728b0e 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -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.