From 05dc2445610b450edaf6c3e8bc28e749f405da67 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 25 Apr 2023 11:24:19 +0000 Subject: [PATCH] [FIX] core: flush after every uninstall hook Confusion between uninstall hooks can apparently trigger errors during uninstallation as two hooks can confuse one another? In this here case, the issue triggered during the uninstall hook of `account_accountant`, which apparently combines with the uninstall hook of `industry_fsm_sale` to trigger an invalid in-memory state for `project_project`. An implicit flush during the hook then blows up with a check constraint error. Flushing at the end of the `industry_fsm_sale` hook or at the start of the `account_accountant` hook fixes the issue, so might as well flush after each hook to ensure whatever they did using models is pushed to the database and in good shape (hopefully). X-original-commit: b28e9a7066d29d395421a11df2b9e170fb20d35a Part-of: odoo/odoo#121522 --- odoo/modules/loading.py | 1 + 1 file changed, 1 insertion(+) diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py index 18faa38ac9b..b98451d0fd6 100644 --- a/odoo/modules/loading.py +++ b/odoo/modules/loading.py @@ -553,6 +553,7 @@ def load_modules(registry, force_demo=False, status=None, update_module=False): if uninstall_hook: py_module = sys.modules['odoo.addons.%s' % (pkg.name,)] getattr(py_module, uninstall_hook)(env) + env.flush_all() Module = env['ir.module.module'] Module.browse(modules_to_remove.values()).module_uninstall()