[FIX] core: ignore imported modules when loading registry

The existing code was generating misleading errors for imported Odoo
modules that could not be loaded.  Although there was a specific hack
for module 'studio_customization', imported modules were not handled
properly.  This patch adds the right condition in the SQL query in the
module that introduces imported modules.

closes odoo/odoo#106098

X-original-commit: e1cfc1f74000e55473f7a26f0df5a13c4d5094c0
Signed-off-by: Vincent Schippefilt (vsc) <vsc@odoo.com>
Signed-off-by: Raphael Collet <rco@odoo.com>
This commit is contained in:
Raphael Collet
2022-11-21 21:18:53 +01:00
parent c10a517ca5
commit f0ca3f32d2
3 changed files with 16 additions and 7 deletions
@@ -25,6 +25,10 @@ class IrModule(models.Model):
imported = fields.Boolean(string="Imported Module")
def _get_modules_to_load_domain(self):
# imported modules are not expected to be loaded as regular modules
return super()._get_modules_to_load_domain() + [('imported', '=', False)]
@api.depends('name')
def _get_latest_version(self):
imported_modules = self.filtered(lambda m: m.imported and m.latest_version)
+4 -1
View File
@@ -328,6 +328,10 @@ class Module(models.Model):
self.clear_caches()
return super(Module, self).unlink()
def _get_modules_to_load_domain(self):
""" Domain to retrieve the modules that should be loaded by the registry. """
return [('state', '=', 'installed')]
@staticmethod
def _check_python_external_dependency(pydep):
try:
@@ -347,7 +351,6 @@ class Module(models.Model):
_logger.warning("get_distribution(%s) failed: %s", pydep, e)
raise Exception('Error finding python library %s' % (pydep,))
@staticmethod
def _check_external_dependencies(terp):
depends = terp.get('external_dependencies')
+8 -6
View File
@@ -483,15 +483,17 @@ def load_modules(registry, force_demo=False, status=None, update_module=False):
['to install'], force, status, report,
loaded_modules, update_module, models_to_check)
# 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]
if module_list:
_logger.error("Some modules are not loaded, some dependencies or manifest may be missing: %s", sorted(module_list))
registry.loaded = True
registry.setup_models(cr)
# check that all installed modules have been loaded by the registry
env = api.Environment(cr, SUPERUSER_ID, {})
Module = env['ir.module.module']
modules = Module.search(Module._get_modules_to_load_domain(), order='name')
missing = [name for name in modules.mapped('name') if name not in graph]
if missing:
_logger.error("Some modules are not loaded, some dependencies or manifest may be missing: %s", missing)
# STEP 3.5: execute migration end-scripts
migrations = odoo.modules.migration.MigrationManager(cr, graph)
for package in graph: