[IMP] core: remove prefetch on Module during loading

If upgrading a database across an addition of a new field to
ir.module.module (which is uncommon but does happen), the field
prefetching would try to load the field before the database schema had
been upgraded, leading to a loading error.

Since we *only* want / need the module's name, we can `search_fetch`
to preload just the field we need, and avoid ancillary
prefetching. It's a bit of an unnecessary optimisation compared to
just turning prefetching off, but it's also simpler (shorter) here
so...

closes odoo/odoo#140010

X-original-commit: c0102ca5dc3507c39f5ae6406fd962419fb09c6e
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
This commit is contained in:
Xavier Morel
2023-10-27 08:36:17 +00:00
parent 3f6f949fa5
commit 781dcdf396
+1 -1
View File
@@ -503,7 +503,7 @@ def load_modules(registry, force_demo=False, status=None, update_module=False):
# check that all installed modules have been loaded by the registry
Module = env['ir.module.module']
modules = Module.search(Module._get_modules_to_load_domain(), order='name')
modules = Module.search_fetch(Module._get_modules_to_load_domain(), ['name'], 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)