[FIX] CI ; [WIP] add get_odoo_addons_path
This commit is contained in:
parent
5776ff5893
commit
b1b64c960f
|
|
@ -37,7 +37,7 @@ pytest:
|
||||||
- echo $PYTHONPATH
|
- echo $PYTHONPATH
|
||||||
- poetry run pytest --version
|
- poetry run pytest --version
|
||||||
|
|
||||||
- # Create a postgresql container
|
# Create a postgresql container
|
||||||
- docker run -v odoo-data:/var/lib/odoo -d -p 8069:8069 --name odoo --link db:db -t odoo
|
- docker run -v odoo-data:/var/lib/odoo -d -p 8069:8069 --name odoo --link db:db -t odoo
|
||||||
|
|
||||||
- poetry run pytest --cov odoo_openupgrade_wizard -v
|
- poetry run pytest --cov odoo_openupgrade_wizard -v
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,37 @@ import docker
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
|
|
||||||
|
# WIP
|
||||||
|
def get_odoo_addons_path(ctx, odoo_version: dict, migration_step: dict) -> str:
|
||||||
|
pass
|
||||||
|
# repo_file = Path(
|
||||||
|
# self._current_directory,
|
||||||
|
# CUSTOMER_CONFIG_FOLDER,
|
||||||
|
# "repo_files",
|
||||||
|
# "%s.yml" % step["version"],
|
||||||
|
# )
|
||||||
|
# folder = Path(self._current_directory, step["local_path"])
|
||||||
|
# base_module_folder = get_base_module_folder(step)
|
||||||
|
# stream = open(repo_file, "r")
|
||||||
|
# data = yaml.safe_load(stream)
|
||||||
|
|
||||||
|
# addons_path = []
|
||||||
|
# for key in data.keys():
|
||||||
|
# path = os.path.join(folder, key)
|
||||||
|
# if path.endswith(get_odoo_folder(step)):
|
||||||
|
# # Add two folder for odoo folder
|
||||||
|
# addons_path.append(os.path.join(path, "addons"))
|
||||||
|
# addons_path.append(
|
||||||
|
# os.path.join(path, base_module_folder, "addons")
|
||||||
|
# )
|
||||||
|
# elif skip_path(step, path):
|
||||||
|
# pass
|
||||||
|
# else:
|
||||||
|
# addons_path.append(path)
|
||||||
|
|
||||||
|
# return ",".join(addons_path)
|
||||||
|
|
||||||
|
|
||||||
def get_odoo_env_path(ctx, odoo_version: dict) -> Path:
|
def get_odoo_env_path(ctx, odoo_version: dict) -> Path:
|
||||||
folder_name = "env_%s" % str(odoo_version["release"]).rjust(4, "0")
|
folder_name = "env_%s" % str(odoo_version["release"]).rjust(4, "0")
|
||||||
return ctx.obj["src_folder_path"] / folder_name
|
return ctx.obj["src_folder_path"] / folder_name
|
||||||
|
|
@ -36,7 +67,12 @@ def get_odoo_version_from_migration_step(ctx, migration_step: dict) -> dict:
|
||||||
|
|
||||||
|
|
||||||
def generate_odoo_command(
|
def generate_odoo_command(
|
||||||
ctx, migration_step: dict, database: str = False, update_all: bool = False
|
ctx,
|
||||||
|
migration_step: dict,
|
||||||
|
database: str,
|
||||||
|
update_all: bool,
|
||||||
|
stop_after_init: bool,
|
||||||
|
shell: bool,
|
||||||
) -> str:
|
) -> str:
|
||||||
# TODO, make it dynamic
|
# TODO, make it dynamic
|
||||||
addons_path = (
|
addons_path = (
|
||||||
|
|
@ -44,24 +80,43 @@ def generate_odoo_command(
|
||||||
)
|
)
|
||||||
database_cmd = database and "--database %s" % database or ""
|
database_cmd = database and "--database %s" % database or ""
|
||||||
update_all_cmd = update_all and "--update_all" or ""
|
update_all_cmd = update_all and "--update_all" or ""
|
||||||
|
stop_after_init_cmd = stop_after_init and "-- stop-after-init" or ""
|
||||||
|
shell_cmd = shell and "shell" or ""
|
||||||
return (
|
return (
|
||||||
f"/container_env/src/odoo/odoo-bin"
|
f"/container_env/src/odoo/odoo-bin"
|
||||||
f" --db_host db"
|
f" --db_host db"
|
||||||
f" --db_port 5432"
|
f" --db_port 5432"
|
||||||
f" --db_user odoo"
|
f" --db_user odoo"
|
||||||
f" --db_password odoo"
|
f" --db_password odoo"
|
||||||
|
f" --workers 0"
|
||||||
f" --addons-path {addons_path}"
|
f" --addons-path {addons_path}"
|
||||||
f" {database_cmd}"
|
f" {database_cmd}"
|
||||||
f" {update_all_cmd}"
|
f" {update_all_cmd}"
|
||||||
|
f" {stop_after_init_cmd}"
|
||||||
|
f" {shell_cmd}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def run_odoo(ctx, migration_step: dict, database: str = False):
|
def run_odoo(
|
||||||
|
ctx,
|
||||||
|
migration_step: dict,
|
||||||
|
database: str = False,
|
||||||
|
stop_after_init: bool = False,
|
||||||
|
shell: bool = False,
|
||||||
|
update_all: bool = False,
|
||||||
|
):
|
||||||
client = docker.from_env()
|
client = docker.from_env()
|
||||||
odoo_version = get_odoo_version_from_migration_step(ctx, migration_step)
|
odoo_version = get_odoo_version_from_migration_step(ctx, migration_step)
|
||||||
folder_path = get_odoo_env_path(ctx, odoo_version)
|
folder_path = get_odoo_env_path(ctx, odoo_version)
|
||||||
|
|
||||||
command = generate_odoo_command(ctx, migration_step, database=database)
|
command = generate_odoo_command(
|
||||||
|
ctx,
|
||||||
|
migration_step,
|
||||||
|
database=database,
|
||||||
|
stop_after_init=stop_after_init,
|
||||||
|
shell=shell,
|
||||||
|
update_all=update_all,
|
||||||
|
)
|
||||||
|
|
||||||
image_name = get_docker_image_tag(ctx, odoo_version)
|
image_name = get_docker_image_tag(ctx, odoo_version)
|
||||||
container_name = get_docker_container_name(ctx, migration_step)
|
container_name = get_docker_container_name(ctx, migration_step)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user