[REM] core: odoo.modules.module.loaded flag
Seems unnecessary, most of the information already lives in `sys.modules`. We can just check that. There are a few changes in behaviour, but they seem minor: - if post_load fails, subsequent attempts to load the module will "succeed" - since we didn't remove/reload the module, a failure because of an incorrect post_load wasn't fixable, however it was possible to update the manifest Still seems like a wonky state to be in, and one we should ignore. Also remove the logging of the error: since we're re-raising as-is, the parent logs it with a traceback, so this is unnecessary and redundant. closes odoo/odoo#103933 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
This commit is contained in:
+7
-13
@@ -60,9 +60,6 @@ _DEFAULT_MANIFEST = {
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
# Modules already loaded
|
||||
loaded = []
|
||||
|
||||
|
||||
class UpgradeHook(object):
|
||||
"""Makes the legacy `migrations` package being `odoo.upgrade`"""
|
||||
@@ -368,27 +365,24 @@ def load_openerp_module(module_name):
|
||||
This is also used to load server-wide module (i.e. it is also used
|
||||
when there is no model to register).
|
||||
"""
|
||||
global loaded
|
||||
if module_name in loaded:
|
||||
|
||||
qualname = f'odoo.addons.{module_name}'
|
||||
if qualname in sys.modules:
|
||||
return
|
||||
|
||||
try:
|
||||
__import__('odoo.addons.' + module_name)
|
||||
__import__(qualname)
|
||||
|
||||
# Call the module's post-load hook. This can done before any model or
|
||||
# data has been initialized. This is ok as the post-load hook is for
|
||||
# server-wide (instead of registry-specific) functionalities.
|
||||
info = get_manifest(module_name)
|
||||
if info['post_load']:
|
||||
getattr(sys.modules['odoo.addons.' + module_name], info['post_load'])()
|
||||
getattr(sys.modules[qualname], info['post_load'])()
|
||||
|
||||
except Exception as e:
|
||||
msg = "Couldn't load module %s" % (module_name)
|
||||
_logger.critical(msg)
|
||||
_logger.critical(e)
|
||||
except Exception:
|
||||
_logger.critical("Couldn't load module %s", module_name)
|
||||
raise
|
||||
else:
|
||||
loaded.append(module_name)
|
||||
|
||||
def get_modules():
|
||||
"""Returns the list of module names
|
||||
|
||||
Reference in New Issue
Block a user