This commit is contained in:
Sylvain LE GAL 2022-06-28 01:06:23 +02:00
parent 429b8013b9
commit b64c445cb4
3 changed files with 59 additions and 23 deletions

View File

@ -153,11 +153,14 @@ def skip_addon_path(migration_step: dict, path: Path) -> bool:
) and migration_step["version"] < 14.0 ) and migration_step["version"] < 14.0
def get_server_wide_modules_upgrade(migration_step: dict) -> list: def get_server_wide_modules_upgrade(
migration_step: dict, execution_context: str = False
) -> list:
"""return a list of modules to load, depending on the migration step.""" """return a list of modules to load, depending on the migration step."""
if ( if (
migration_step["version"] >= 14.0 migration_step["version"] >= 14.0
and migration_step["execution_context"] == "openupgrade" and migration_step["execution_context"] == "openupgrade"
and execution_context != "regular"
): ):
return ["openupgrade_framework"] return ["openupgrade_framework"]
return [] return []

View File

@ -1,4 +1,4 @@
# import configparser import configparser
import csv import csv
import os import os
import sys import sys
@ -8,11 +8,11 @@ from pathlib import Path
import yaml import yaml
from loguru import logger from loguru import logger
# get_server_wide_modules_upgrade,
from odoo_openupgrade_wizard.configuration_version_dependant import ( from odoo_openupgrade_wizard.configuration_version_dependant import (
get_base_module_folder, get_base_module_folder,
get_odoo_folder, get_odoo_folder,
get_odoo_run_command, get_odoo_run_command,
get_server_wide_modules_upgrade,
skip_addon_path, skip_addon_path,
) )
from odoo_openupgrade_wizard.tools.tools_docker import ( from odoo_openupgrade_wizard.tools.tools_docker import (
@ -209,19 +209,14 @@ def run_odoo(
shell=shell, shell=shell,
demo=demo, demo=demo,
) )
host_xmlrpc_port = (
alternative_xml_rpc_port
and alternative_xml_rpc_port
or ctx.obj["config"]["odoo_host_xmlrpc_port"]
)
return run_container_odoo( return run_container_odoo(
ctx, ctx,
migration_step, migration_step,
command, command,
host_xmlrpc_port,
detached_container=detached_container, detached_container=detached_container,
database=database, database=database,
alternative_xml_rpc_port=alternative_xml_rpc_port,
) )
@ -229,19 +224,64 @@ def run_container_odoo(
ctx, ctx,
migration_step: dict, migration_step: dict,
command: str, command: str,
host_xmlrpc_port: int,
detached_container: bool = False, detached_container: bool = False,
database: str = False, database: str = False,
alternative_xml_rpc_port: int = False,
execution_context: str = False,
log_file_suffix: str = "", log_file_suffix: str = "",
links: dict = {}, links: dict = {},
): ):
log_file = "/env/log/{}____{}{}.log".format(
ctx.obj["log_prefix"], migration_step["complete_name"], log_file_suffix
)
env_path = ctx.obj["env_folder_path"] env_path = ctx.obj["env_folder_path"]
odoo_env_path = get_odoo_env_path(ctx, migration_step["version"]) odoo_env_path = get_odoo_env_path(ctx, migration_step["version"])
# Compute 'server_wide_modules'
# For that purpose, read the custom odoo.cfg file
# to know if server_wide_modules is defined
custom_odoo_config_file = odoo_env_path / "odoo.cfg"
parser = configparser.RawConfigParser()
parser.read(custom_odoo_config_file)
server_wide_modules = parser.get(
"options", "server_wide_modules", fallback=[]
)
server_wide_modules += get_server_wide_modules_upgrade(
migration_step, execution_context
)
# compute 'addons_path'
addons_path = ",".join(
[
str(x)
for x in get_odoo_addons_path(
ctx, Path("/odoo_env"), migration_step, execution_context
)
]
)
# compute 'log_file'
log_file = "/env/log/{}____{}{}.log".format(
ctx.obj["log_prefix"], migration_step["complete_name"], log_file_suffix
)
host_xmlrpc_port = (
alternative_xml_rpc_port
and alternative_xml_rpc_port
or ctx.obj["config"]["odoo_host_xmlrpc_port"]
)
links.update({ctx.obj["config"]["postgres_container_name"]: "db"}) links.update({ctx.obj["config"]["postgres_container_name"]: "db"})
environments = {
"DB_HOST": "db",
"DB_PORT": 5432,
"DB_USER": "odoo",
"DB_PASSWORD": "odoo",
"DB_NAME": database,
"LOGFILE": log_file,
"ADDONS_PATH": addons_path,
"WORKERS": 0,
}
if server_wide_modules:
environments["SERVER_WIDE_MODULES"] = ",".join(server_wide_modules)
return run_container( return run_container(
get_docker_image_tag(ctx, migration_step["version"]), get_docker_image_tag(ctx, migration_step["version"]),
get_docker_container_name(ctx, migration_step), get_docker_container_name(ctx, migration_step),
@ -253,14 +293,7 @@ def run_container_odoo(
env_path: "/env/", env_path: "/env/",
odoo_env_path: "/odoo_env/", odoo_env_path: "/odoo_env/",
}, },
environments={ environments=environments,
"DB_HOST": "db",
"DB_PORT": 5432,
"DB_USER": "odoo",
"DB_PASSWORD": "odoo",
"DB_NAME": database,
"LOGFILE": log_file,
},
links=links, links=links,
detach=detached_container, detach=detached_container,
auto_remove=True, auto_remove=True,

View File

@ -14,9 +14,9 @@ odoo_versions:
odoo_version_settings: odoo_version_settings:
13.0: 13.0:
python_minor_version_short: py37 repo_url: False
14.0: 14.0:
python_minor_version_short: py39 repo_url: False
migration_steps: migration_steps: