From 8d5aaaa0e29347a64c66fa2e22721e8cd1fe407b Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 7 Jan 2021 10:29:31 +0000 Subject: [PATCH] [FIX] core: check module state inconsistencies after `end` upgrade scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some modules may be removed by the upgrade scripts with the help of the ORM and are done in `end` scripts. This is the case for uninstalling the themes which use the `_theme_remove` method [1]. [1] in 12.0: https://github.com/odoo/odoo/blob/e2084a4356f63249920d8c777e92f1710be8b5a6/addons/website_theme_install/models/ir_module_module.py#L337 closes odoo/odoo#64219 X-original-commit: e5ab5410dbc006fc4bcdd21e603026483bf5d360 Signed-off-by: Xavier Dollé (xdo) Signed-off-by: Christophe Simonis --- odoo/modules/loading.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py index 1f2c4df751d..3ffbe90dd51 100644 --- a/odoo/modules/loading.py +++ b/odoo/modules/loading.py @@ -470,12 +470,6 @@ def load_modules(db, force_demo=False, status=None, update_module=False): ['to install'], force, status, report, loaded_modules, update_module, models_to_check) - # check that new module dependencies have been properly installed after a migration/upgrade - cr.execute("SELECT name from ir_module_module WHERE state IN ('to install', 'to upgrade')") - module_list = [name for (name,) in cr.fetchall()] - if module_list: - _logger.error("Some modules have inconsistent states, some dependencies may be missing: %s", sorted(module_list)) - # check that all installed modules have been loaded by the registry after a migration/upgrade cr.execute("SELECT name from ir_module_module WHERE state = 'installed' and name != 'studio_customization'") module_list = [name for (name,) in cr.fetchall() if name not in graph] @@ -490,6 +484,12 @@ def load_modules(db, force_demo=False, status=None, update_module=False): for package in graph: migrations.migrate_module(package, 'end') + # check that new module dependencies have been properly installed after a migration/upgrade + cr.execute("SELECT name from ir_module_module WHERE state IN ('to install', 'to upgrade')") + module_list = [name for (name,) in cr.fetchall()] + if module_list: + _logger.error("Some modules have inconsistent states, some dependencies may be missing: %s", sorted(module_list)) + # STEP 3.6: apply remaining constraints in case of an upgrade registry.finalize_constraints()