[IMP] make odoo command depending on migration_step

This commit is contained in:
Sylvain LE GAL 2022-04-28 01:48:21 +02:00
parent eb3af378e8
commit 006d998332
2 changed files with 32 additions and 1 deletions

View File

@ -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"

View File

@ -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"