From 744f5791bbdcd54fdf722edb0eed226ecf7c681e Mon Sep 17 00:00:00 2001 From: "Florian(flg)" Date: Wed, 20 Sep 2023 10:03:12 +0000 Subject: [PATCH] [FIX] account: Fix reload template from chart template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All account.tax weren't delete when we reload the chart template. It was caused by the fact that we forgot to add the active_test=False in the context to delete all the taxes (and not only the actives). This thing caused an issue where an sql constrains was trigger. This fix comes from another PR (https://github.com/odoo/odoo/pull/132360) that doesn't solve properly the issue. closes odoo/odoo#136081 X-original-commit: a92f347318415492357413c577e666785c2cb8a4 Signed-off-by: William André (wan) Signed-off-by: Florian Gilbert (flg) --- addons/account/models/chart_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index 5ebc345f36a..79d176c53f4 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -175,7 +175,7 @@ class AccountChartTemplate(models.AbstractModel): if not reload_template and (not company._existing_accounting() or self.env.ref('base.module_account').demo): for model in ('account.move',) + TEMPLATE_MODELS[::-1]: if not company.parent_id: - self.env[model].sudo().search([('company_id', 'child_of', company.id)]).with_context({MODULE_UNINSTALL_FLAG: True}).unlink() + self.env[model].sudo().with_context(active_test=False).search([('company_id', 'child_of', company.id)]).with_context({MODULE_UNINSTALL_FLAG: True}).unlink() data = self._get_chart_template_data(template_code) template_data = data.pop('template_data')