From b2feb8b7f44ca326e327e203206fa75f6245f61c Mon Sep 17 00:00:00 2001 From: wan Date: Fri, 3 Jan 2020 15:35:48 +0000 Subject: [PATCH] [FIX] account: change CoA even if one already installed Because the tax closing entry is created (empty) at the creation of the CoA, it is not possible anymore to change it later, even if the user didn't create any journal entry. By checking that there are no account.move.line instead of account.move, and also there are no entries with a name different from '/' (to ensure that the sequences are untouched) we can change the CoA if needed. closes odoo/odoo#44659 X-original-commit: 8928dfe70867da3e40fa47f50bffa5dfd1976090 Signed-off-by: wan --- addons/account/models/chart_template.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index 21b05a3049b..c0558d962d7 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -272,10 +272,12 @@ class AccountChartTemplate(models.Model): the provided company (meaning hence that its chart of accounts cannot be changed anymore). """ - model_to_check = ['account.move', 'account.payment', 'account.bank.statement'] + model_to_check = ['account.move.line', 'account.payment', 'account.bank.statement'] for model in model_to_check: if self.env[model].sudo().search([('company_id', '=', company_id.id)], limit=1): return True + if self.env['account.move'].sudo().search([('company_id', '=', company_id.id), ('name', '!=', '/')], limit=1): + return True return False def _create_tax_templates_from_rates(self, company_id, sale_tax_rate, purchase_tax_rate):