From f8ca384ba76b6c417cd98537583bbdb93732bff1 Mon Sep 17 00:00:00 2001 From: oco-odoo Date: Tue, 20 Apr 2021 12:16:27 +0000 Subject: [PATCH] [IMP] account: error message when no country can be inferred for taxes when installing the CoA Generic chart of accounts such as Syscohada don't have any country_id set. When installing them on a company without any account_fiscal_country_id, no country could be assigned to the account.tax being created, hence crashing, as country_id is required on account.tax. We now prevent that by raising a more comprehensive error. closes odoo/odoo#69593 X-original-commit: a253bf331b2448194106523b9c3d753fb6ddd04a Signed-off-by: Laurent Smet Signed-off-by: oco-odoo --- addons/account/i18n/account.pot | 6 ++++++ addons/account/models/chart_template.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index 4ed3ca33460..ef2840dbafe 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -8829,6 +8829,12 @@ msgstr "" msgid "Please define a payment method on your payment." msgstr "" +#. module: account +#: code:addons/account/models/chart_template.py:0 +#, python-format +msgid "Please first define a fiscal country for company %s." +msgstr "" + #. module: account #: code:addons/account/models/account_bank_statement.py:0 #, python-format diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index f9fcb59161a..8c83a33bf1b 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -1022,6 +1022,11 @@ class AccountTaxTemplate(models.Model): if self.chart_template_id.country_id: vals['country_id'] = self.chart_template_id.country_id.id + elif company.account_fiscal_country_id: + vals['country_id'] = company.account_fiscal_country_id.id + else: + # Will happen for generic CoAs such as syscohada (they are available for multiple countries, and don't have any country_id) + raise UserError(_("Please first define a fiscal country for company %s.", company.name)) tax_template_vals.append((template, vals)) else: