From 9dceea18187885ed10f64d8c086d5b435b4531bf Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Tue, 26 Oct 2021 11:32:17 +0000 Subject: [PATCH] [IMP] core: skip (setup|init)_models for module without models Some modules are only adding data/tests/routes/static content. In this case, it is useless to check the database schema or setup models in registry. closes odoo/odoo#78898 Signed-off-by: Raphael Collet (rco) --- odoo/modules/loading.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py index f62b7539d5b..2c2babf0414 100644 --- a/odoo/modules/loading.py +++ b/odoo/modules/loading.py @@ -193,18 +193,19 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, mode = 'init' loaded_modules.append(package.name) - if needs_update: - models_updated |= set(model_names) - models_to_check -= set(model_names) - registry.setup_models(cr) - registry.init_models(cr, model_names, {'module': package.name}, new_install) - elif package.state != 'to remove': - # The current module has simply been loaded. The models extended by this module - # and for which we updated the schema, must have their schema checked again. - # This is because the extension may have changed the model, - # e.g. adding required=True to an existing field, but the schema has not been - # updated by this module because it's not marked as 'to upgrade/to install'. - models_to_check |= set(model_names) & models_updated + if model_names: + if needs_update: + models_updated |= set(model_names) + models_to_check -= set(model_names) + registry.setup_models(cr) + registry.init_models(cr, model_names, {'module': package.name}, new_install) + elif package.state != 'to remove': + # The current module has simply been loaded. The models extended by this module + # and for which we updated the schema, must have their schema checked again. + # This is because the extension may have changed the model, + # e.g. adding required=True to an existing field, but the schema has not been + # updated by this module because it's not marked as 'to upgrade/to install'. + models_to_check |= set(model_names) & models_updated idref = {}