diff --git a/odoo_openupgrade_wizard/configuration_version_dependant.py b/odoo_openupgrade_wizard/configuration_version_dependant.py index c6688ae..a256019 100644 --- a/odoo_openupgrade_wizard/configuration_version_dependant.py +++ b/odoo_openupgrade_wizard/configuration_version_dependant.py @@ -82,3 +82,25 @@ def get_odoo_versions(initial_release: float, final_release: float) -> list: ): result.append(version_template) return result + + +def get_odoo_run_command(migration_step: dict) -> str: + """Return the name of the command to execute, depending on the migration + step. (odoo-bin, odoo.py, etc...)""" + if migration_step["release"] >= 9.0: + return "odoo-bin" + + return "odoo.py" + + +def get_odoo_folder(migration_step: dict) -> str: + """return the main odoo folder, depending on the migration step. + (./src/odoo, ./src/openupgrade, ...)""" + + if migration_step["action"] == "update": + return "./src/odoo" + + if migration_step["release"] >= 14.0: + return "./src/odoo" + + return "./src/openupgrade" diff --git a/odoo_openupgrade_wizard/tools_odoo.py b/odoo_openupgrade_wizard/tools_odoo.py index 9b68f0c..3ee3f79 100644 --- a/odoo_openupgrade_wizard/tools_odoo.py +++ b/odoo_openupgrade_wizard/tools_odoo.py @@ -2,6 +2,10 @@ from pathlib import Path import yaml +from odoo_openupgrade_wizard.configuration_version_dependant import ( + get_odoo_folder, + get_odoo_run_command, +) from odoo_openupgrade_wizard.tools_docker import kill_container, run_container @@ -85,8 +89,13 @@ def generate_odoo_command( log_file = "/env/log/{}____{}.log".format( ctx.obj["log_prefix"], migration_step["complete_name"] ) + command = ( + Path("/odoo_env") + / Path(get_odoo_folder(migration_step)) + / Path(get_odoo_run_command(migration_step)) + ) result = ( - f"/odoo_env/src/odoo/odoo-bin" + f" {command}" f" {shell_cmd}" f" --db_host db" f" --db_port 5432"