From 05978d603bc0c293e165f72841d9a3f4ddab271d Mon Sep 17 00:00:00 2001 From: "Claire Bretton (clbr)" Date: Thu, 31 Aug 2023 14:38:45 +0000 Subject: [PATCH] [FIX] account: Reload chart_template button unexpected unlink MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reload button appeared when no chart_template was set which could make Odoo delete important data if clicked. We restrict appearance of the reload button to avoid this situation. Also adds a short description on the button to notify user of the irreversability of the action. Steps to reproduce: 1. Create a company (do not use the default one that has Generic CoA set) with a country set. 2. Create accounts : income, receivable and payable. 3. Create a sale journal with the income account. 4. Go to a partner detail (e.g. Deco addict), tab Accounting and set its receivable/payable accounts to the ones created above. 5. Create an invoice for that partner. 6. Go in Accounting Settings and click the reload button. => The invoice is deleted. Task-3488427 OPW-3448881 closes odoo/odoo#134028 X-original-commit: a636b9386f297f9f08a38689911ca111fe597ec3 Signed-off-by: William André (wan) Signed-off-by: Claire Bretton (clbr) --- addons/account/models/chart_template.py | 2 +- addons/account/views/res_config_settings_views.xml | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index 91bee05ea36..07dad4c1b96 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -172,7 +172,7 @@ class AccountChartTemplate(models.AbstractModel): reload_template = template_code == company.chart_template company.chart_template = template_code - if not reload_template: + 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() diff --git a/addons/account/views/res_config_settings_views.xml b/addons/account/views/res_config_settings_views.xml index 3e59289fa62..c051f8133dc 100644 --- a/addons/account/views/res_config_settings_views.xml +++ b/addons/account/views/res_config_settings_views.xml @@ -33,7 +33,9 @@
-