From 250fbe2d4e197ea1c0ef17d216005c01d335dcbb Mon Sep 17 00:00:00 2001 From: Guillaume MASSON Date: Wed, 17 May 2023 18:13:01 +0200 Subject: [PATCH] [FIX] upgrade_analysis : avoid KeyError "module" Check "module" is in context when patching init_models --- .../odoo_patch/odoo/modules/registry.py | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/upgrade_analysis/odoo_patch/odoo/modules/registry.py b/upgrade_analysis/odoo_patch/odoo/modules/registry.py index 017da063f..c71f2ce20 100644 --- a/upgrade_analysis/odoo_patch/odoo/modules/registry.py +++ b/upgrade_analysis/odoo_patch/odoo/modules/registry.py @@ -15,18 +15,19 @@ class RegistryPatch(OdooPatch): method_names = ["init_models"] def init_models(self, cr, model_names, context, install=True): - module_name = context["module"] - _logger.debug("Logging models of module %s", module_name) - upg_registry = current_thread()._upgrade_registry - local_registry = {} - env = api.Environment(cr, SUPERUSER_ID, {}) - for model in env.values(): - if not model._auto: - continue - upgrade_log.log_model(model, local_registry) - upgrade_log.compare_registries( - cr, context["module"], upg_registry, local_registry - ) + if "module" in context: + module_name = context["module"] + _logger.debug("Logging models of module %s", module_name) + upg_registry = current_thread()._upgrade_registry + local_registry = {} + env = api.Environment(cr, SUPERUSER_ID, {}) + for model in env.values(): + if not model._auto: + continue + upgrade_log.log_model(model, local_registry) + upgrade_log.compare_registries( + cr, context["module"], upg_registry, local_registry + ) return RegistryPatch.init_models._original_method( self, cr, model_names, context, install=install