diff options
Diffstat (limited to 'odoo/modules')
| -rw-r--r-- | odoo/modules/migration.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/odoo/modules/migration.py b/odoo/modules/migration.py index 6331af43660..8faf8735a8d 100644 --- a/odoo/modules/migration.py +++ b/odoo/modules/migration.py @@ -19,7 +19,7 @@ _logger = logging.getLogger(__name__) def load_script(path, module_name): - full_path = get_resource_path(*path.split(os.path.sep)) + full_path = get_resource_path(*path.split(os.path.sep)) if not os.path.isabs(path) else path spec = importlib.util.spec_from_file_location(module_name, full_path) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) @@ -62,6 +62,13 @@ class MigrationManager(object): self._get_files() def _get_files(self): + def _get_upgrades_paths(pkg): + for path in tools.config['upgrades_paths'].split(','): + upgrade_path = opj(path, pkg) + if os.path.exists(upgrade_path): + return upgrade_path + return None + def get_scripts(path): if not path: return {} @@ -78,7 +85,10 @@ class MigrationManager(object): self.migrations[pkg.name] = { 'module': get_scripts(get_resource_path(pkg.name, 'migrations')), + 'module_upgrades': get_scripts(get_resource_path(pkg.name, 'upgrades')), 'maintenance': get_scripts(get_resource_path('base', 'maintenance', 'migrations', pkg.name)), + 'maintenance_upgrades': get_scripts(get_resource_path('base', 'maintenance', 'upgrades', pkg.name)), + 'upgrades': get_scripts(_get_upgrades_paths(pkg.name)), } def migrate_module(self, pkg, stage): @@ -122,9 +132,16 @@ class MigrationManager(object): mapping = { 'module': opj(pkg.name, 'migrations'), + 'module_upgrades': opj(pkg.name, 'upgrades'), 'maintenance': opj('base', 'maintenance', 'migrations', pkg.name), + 'maintenance_upgrades': opj('base', 'maintenance', 'upgrades', pkg.name), } + for path in tools.config['upgrades_paths'].split(','): + if os.path.exists(opj(path, pkg.name)): + mapping['upgrades'] = opj(path, pkg.name) + break + for x in mapping: if version in m.get(x): for f in m[x][version]: |
