diff options
| author | Laurent Contzen <lco@odoo.com> | 2019-04-11 09:48:35 +0000 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-08-05 12:21:00 +0000 |
| commit | bbb1a8f151b07d0125fc6d7d89375aa22681aac5 (patch) | |
| tree | bf5ccedb87685b8901ad30c10742a1ae7c4adcd6 /odoo/tools/config.py | |
| parent | 6edb18be0d58a77c760668c006307ddf7dfd4935 (diff) | |
[IMP] ORM: Add new --upgrades-paths CLI option
This commit adds a new way to use upgrades scripts folders
whithout needing to symlink them to an hardcoded path.
The folders specified in --upgrades-paths is then being used by
migration.py to find and execute migrations scripts per module
specified in the -u CLI option.
The folder needs to have the following structure:
- <upgrades_paths folder 1>
- <module1 name>
- <version1>
- <script1>
- <script2>
- ...
- <scriptn>
- <version2>
- <scripts>
- <module2 name>
- <versions>
- <scripts>
- ...
- <upgrades_paths folder 2>
- ...
Update odoo/tools/config.py
Co-Authored-By: Olivier Dony <odony@users.noreply.github.com>
Diffstat (limited to 'odoo/tools/config.py')
| -rw-r--r-- | odoo/tools/config.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/odoo/tools/config.py b/odoo/tools/config.py index ef409de56f9..677628835b4 100644 --- a/odoo/tools/config.py +++ b/odoo/tools/config.py @@ -118,6 +118,9 @@ class configmanager(object): group.add_option("--addons-path", dest="addons_path", help="specify additional addons paths (separated by commas).", action="callback", callback=self._check_addons_path, nargs=1, type="string") + group.add_option("--upgrades-paths", dest="upgrades_paths", + help="specify an additional upgrades path.", + action="callback", callback=self._check_upgrades_paths, nargs=1, type="string") group.add_option("--load", dest="server_wide_modules", help="Comma-separated list of server-wide modules.", my_default='base,web') group.add_option("-D", "--data-dir", dest="data_dir", my_default=_get_default_datadir(), @@ -420,7 +423,7 @@ class configmanager(object): 'db_name', 'db_user', 'db_password', 'db_host', 'db_sslmode', 'db_port', 'db_template', 'logfile', 'pidfile', 'smtp_port', 'email_from', 'smtp_server', 'smtp_user', 'smtp_password', - 'db_maxconn', 'import_partial', 'addons_path', + 'db_maxconn', 'import_partial', 'addons_path', 'upgrades_paths', 'syslog', 'without_demo', 'screencasts', 'screenshots', 'dbfilter', 'log_level', 'log_db', 'log_db_level', 'geoip_database', 'dev_mode', 'shell_interface' @@ -485,6 +488,13 @@ class configmanager(object): os.path.abspath(os.path.expanduser(os.path.expandvars(x.strip()))) for x in self.options['addons_path'].split(',')) + self.options['upgrades_paths'] = ( + ",".join(os.path.abspath(os.path.expanduser(os.path.expandvars(x.strip()))) + for x in self.options['upgrades_paths'].split(',')) + if self.options['upgrades_paths'] + else "" + ) + self.options['data_dir'] = os.path.abspath(os.path.expanduser(os.path.expandvars(self.options['data_dir'].strip()))) self.options['init'] = opt.init and dict.fromkeys(opt.init.split(','), 1) or {} @@ -539,6 +549,16 @@ class configmanager(object): setattr(parser.values, option.dest, ",".join(ad_paths)) + def _check_upgrades_paths(self, option, opt, value, parser): + upgrades_paths = [] + for path in value.split(','): + path = path.strip() + res = os.path.abspath(os.path.expanduser(os.path.expandvars(path))) + if not os.path.isdir(res): + raise optparse.OptionValueError("option %s: no such directory: %r" % (opt, path)) + upgrades_paths.append(res) + setattr(parser.values, option.dest, ",".join(upgrades_paths)) + def _test_enable_callback(self, option, opt, value, parser): if not parser.values.test_tags: parser.values.test_tags = "+standard" |
