From 6f2bc37129f28387f342eccb73e8aa2f62e08e80 Mon Sep 17 00:00:00 2001 From: Xavier ALT Date: Tue, 4 Apr 2023 12:10:51 +0000 Subject: [PATCH] [FIX] account: fix switching of CoA with only Invoicing app installed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When only Invoicing app is installed, trying to switch from a CoA with reconcile model result in the following error: You are not allowed to delete 'Preset to create journal entries during a invoices and payments matching' (account.reconcile.model) records. This operation is allowed for the following groups: - Technical/Show Full Accounting Features Contact your administrator to request access if necessary. As we already checked that user doing that operation is an admin., we do remove the preceding CoA a superuser (like it was done precedingly in saas~16.1). To reproduce: - Install a database without demo data and choose "Germany" as country - Install "Invoicing" app * this automatically install SKR 03 chart of account * - Go to Settings / Invoicing, switch chart template to SKR 04 and Save * raise the error above * closes odoo/odoo#117788 X-original-commit: 87af732ba99b0fd79a98aa0c0c09ca1f737f9955 Signed-off-by: William André (wan) Signed-off-by: Xavier Alt (xal) --- 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 57e0938dd38..e56238ed080 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -173,7 +173,7 @@ class AccountChartTemplate(models.AbstractModel): if not reload_template: for model in ('account.move',) + TEMPLATE_MODELS[::-1]: - self.env[model].search([('company_id', '=', company.id)]).with_context({MODULE_UNINSTALL_FLAG: True}).unlink() + self.env[model].sudo().search([('company_id', '=', company.id)]).with_context({MODULE_UNINSTALL_FLAG: True}).unlink() data = self._get_chart_template_data(template_code) template_data = data.pop('template_data')