-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addons autoinstaller and env-based filter (#84)
- Allow to define enabled addons by environment variables. - Brand-new `addons-install` script that installs all available addons for the environment.
- Loading branch information
Showing
10 changed files
with
287 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env python | ||
from __future__ import print_function | ||
import sys | ||
from argparse import ArgumentParser | ||
from subprocess import check_call | ||
from odoobaselib import addons_config, CORE, PRIVATE, logging | ||
|
||
# Define CLI options | ||
parser = ArgumentParser(description="Install addons in current environment") | ||
parser.add_argument( | ||
"-c", "--core", action="store_true", | ||
help="Install all Odoo core addons") | ||
parser.add_argument( | ||
"-e", "--extra", action="store_true", | ||
help="Install all extra addons") | ||
parser.add_argument( | ||
"-l", "--list", action="store_true", | ||
help="Only list addons instead of installing them") | ||
parser.add_argument( | ||
"-p", "--private", action="store_true", | ||
help="Install all private addons") | ||
parser.add_argument( | ||
"-s", "--separator", type=str, default=",", | ||
help="String that separates addons when using --list") | ||
parser.add_argument( | ||
"-t", "--test", action="store_true", | ||
help="Run unit tests for these addons, usually combined with --update") | ||
parser.add_argument( | ||
"-u", "--update", action="store_true", | ||
help="Update addons instead of installing them") | ||
|
||
# Check no CLI conflicts | ||
args = parser.parse_args() | ||
if not (args.private or args.core or args.extra): | ||
parser.error("You have to choose an option at least") | ||
if args.list and args.update: | ||
parser.error("Cannot --list and --update together") | ||
if args.separator != "," and not args.list: | ||
parser.error("Cannot use --separator without --list") | ||
|
||
# Generate the matching addons set | ||
addons = set() | ||
for addon, repo in addons_config(): | ||
core_ok = args.core and repo == CORE | ||
extra_ok = args.extra and repo not in {CORE, PRIVATE} | ||
private_ok = args.private and repo == PRIVATE | ||
if private_ok or core_ok or extra_ok: | ||
addons.add(addon) | ||
|
||
# Do the required action | ||
if not addons: | ||
sys.exit("No addons found") | ||
addons = args.separator.join(sorted(addons)) | ||
if args.list: | ||
print(addons) | ||
else: | ||
command = ["odoo", "--stop-after-init"] | ||
if args.test: | ||
command += ["--test-enable", "--workers", "0"] | ||
command += ["--update" if args.update else "--init", addons] | ||
logging.info("Executing %s", " ".join(command)) | ||
check_call(command) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[options] | ||
; Addons in priority order: private, then other repos, then base Odoo | ||
addons_path = /opt/odoo/custom/src/private,/opt/odoo/auto/addons,/opt/odoo/custom/src/odoo/addons | ||
addons_path = /opt/odoo/auto/addons |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.