summaryrefslogtreecommitdiff
path: root/odoo/modules/module.py
diff options
context:
space:
mode:
Diffstat (limited to 'odoo/modules/module.py')
-rw-r--r--odoo/modules/module.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/odoo/modules/module.py b/odoo/modules/module.py
index 851395ba280..dd8fde100f2 100644
--- a/odoo/modules/module.py
+++ b/odoo/modules/module.py
@@ -39,20 +39,41 @@ def initialize_sys_path():
and explicit directories.
"""
+ # hook odoo.addons on data dir
dd = os.path.normcase(tools.config.addons_data_dir)
if os.access(dd, os.R_OK) and dd not in odoo.addons.__path__:
odoo.addons.__path__.append(dd)
+ # hook odoo.addons on addons paths
for ad in tools.config['addons_path'].split(','):
ad = os.path.normcase(os.path.abspath(tools.ustr(ad.strip())))
if ad not in odoo.addons.__path__:
odoo.addons.__path__.append(ad)
- # add base module path
+ # hook odoo.addons on base module path
base_path = os.path.normcase(os.path.abspath(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'addons')))
if base_path not in odoo.addons.__path__ and os.path.isdir(base_path):
odoo.addons.__path__.append(base_path)
+ # hook odoo.upgrades on upgrades paths
+ from odoo import upgrades
+ for up in tools.config['upgrades_paths'].split(','):
+ up = os.path.normcase(os.path.abspath(tools.ustr(up.strip())))
+ if up not in upgrades.__path__:
+ upgrades.__path__.append(up)
+
+ # hook odoo.upgrades on legacy odoo/addons/base/maintenance/migrations symlink
+ if not tools.config['upgrades_paths']:
+ upgrades.__path__.append(os.path.join(
+ base_path, 'base', 'maintenance', 'migrations'))
+
+ # create decrecated module alias from odoo.addons.base.maintenance.migrations to odoo.upgrades
+ spec = importlib.machinery.ModuleSpec("odoo.addons.base.maintenance", None, is_package=True)
+ maintenance_pkg = importlib.util.module_from_spec(spec)
+ maintenance_pkg.migrations = upgrades
+ sys.modules["odoo.addons.base.maintenance"] = maintenance_pkg
+ sys.modules["odoo.addons.base.maintenance.migrations"] = upgrades
+
def get_module_path(module, downloaded=False, display_warning=True):
"""Return the path of the given module.