summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odoo/modules/module.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/odoo/modules/module.py b/odoo/modules/module.py
index 6b7065a05ad..f445b8d1436 100644
--- a/odoo/modules/module.py
+++ b/odoo/modules/module.py
@@ -88,6 +88,32 @@ class OdooHook(object):
return sys.modules[name]
+class UpgradeHook(object):
+ """Makes the legacy `migrations` package being `odoo.upgrade`"""
+
+ def find_module(self, name, path=None):
+ if re.match(r"^odoo.addons.base.maintenance.migrations\b", name):
+ # We can't trigger a DeprecationWarning in this case.
+ # In order to be cross-versions, the multi-versions upgrade scripts (0.0.0 scripts),
+ # the tests, and the common files (utility functions) still needs to import from the
+ # legacy name.
+ return self
+
+ def load_module(self, name):
+ assert name not in sys.modules
+
+ canonical_upgrade = name.replace("odoo.addons.base.maintenance.migrations", "odoo.upgrade")
+
+ if canonical_upgrade in sys.modules:
+ mod = sys.modules[canonical_upgrade]
+ else:
+ mod = importlib.import_module(canonical_upgrade)
+
+ sys.modules[name] = mod
+
+ return sys.modules[name]
+
+
def initialize_sys_path():
"""
Setup the addons path ``odoo.addons.__path__`` with various defaults
@@ -126,6 +152,7 @@ def initialize_sys_path():
# hook deprecated module alias from openerp to odoo and "crm"-like to odoo.addons
if not getattr(initialize_sys_path, 'called', False): # only initialize once
+ sys.meta_path.insert(0, UpgradeHook())
sys.meta_path.insert(0, OdooHook())
sys.meta_path.insert(0, AddonsHook())
initialize_sys_path.called = True