[FIX] account: Fix reload template from chart template

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) <wan@odoo.com>
Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
This commit is contained in:
Florian(flg)
2023-09-21 06:31:02 +00:00
parent 657314adb1
commit 744f5791bb
+1 -1
View File
@@ -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')