[IMP] compute dynamically addons_path
This commit is contained in:
parent
006d998332
commit
fa5d9913a2
|
|
@ -1,3 +1,5 @@
|
|||
from pathlib import Path
|
||||
|
||||
# See : https://github.com/OCA/openupgradelib/issues/248
|
||||
# https://github.com/OCA/openupgradelib/issues/288
|
||||
_LEGACY_OPENUPGRADELIB = (
|
||||
|
|
@ -98,9 +100,27 @@ def get_odoo_folder(migration_step: dict) -> str:
|
|||
(./src/odoo, ./src/openupgrade, ...)"""
|
||||
|
||||
if migration_step["action"] == "update":
|
||||
return "./src/odoo"
|
||||
return "src/odoo"
|
||||
|
||||
if migration_step["release"] >= 14.0:
|
||||
return "./src/odoo"
|
||||
return "src/odoo"
|
||||
|
||||
return "./src/openupgrade"
|
||||
return "src/openupgrade"
|
||||
|
||||
|
||||
def get_base_module_folder(migration_step: dict) -> str:
|
||||
"""return the name of the folder (odoo, openerp, etc...)
|
||||
where the 'base' module is, depending on the migration_step"""
|
||||
if migration_step["release"] >= 10.0:
|
||||
return "odoo"
|
||||
|
||||
return "openerp"
|
||||
|
||||
|
||||
def skip_addon_path(migration_step: dict, path: Path) -> bool:
|
||||
# if repo.yml contains both odoo and openupgrade repo
|
||||
# we skip one of them (before the refactoring)
|
||||
return (
|
||||
str(path).endswith("/src/odoo")
|
||||
or str(path).endswith("src/openupgrade")
|
||||
) and migration_step["release"] < 14.0
|
||||
|
|
|
|||
|
|
@ -3,37 +3,39 @@ from pathlib import Path
|
|||
import yaml
|
||||
|
||||
from odoo_openupgrade_wizard.configuration_version_dependant import (
|
||||
get_base_module_folder,
|
||||
get_odoo_folder,
|
||||
get_odoo_run_command,
|
||||
skip_addon_path,
|
||||
)
|
||||
from odoo_openupgrade_wizard.tools_docker import kill_container, run_container
|
||||
|
||||
|
||||
# WIP
|
||||
def get_odoo_addons_path(ctx, migration_step: dict) -> str:
|
||||
def get_odoo_addons_path(ctx, root_path: Path, migration_step: dict) -> str:
|
||||
odoo_version = get_odoo_version_from_migration_step(ctx, migration_step)
|
||||
repo_file = get_odoo_env_path(ctx, odoo_version) / Path("repos.yml")
|
||||
# folder = Path(self._current_directory, step["local_path"])
|
||||
# base_module_folder = get_base_module_folder(step)
|
||||
base_module_folder = get_base_module_folder(migration_step)
|
||||
stream = open(repo_file, "r")
|
||||
data = yaml.safe_load(stream)
|
||||
data = data
|
||||
|
||||
# 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)
|
||||
addons_path = []
|
||||
for key in data.keys():
|
||||
path = root_path / Path(key)
|
||||
print(path)
|
||||
if str(path).endswith(get_odoo_folder(migration_step)):
|
||||
# Add two folder for odoo folder
|
||||
addons_path.append(path / Path("addons"))
|
||||
addons_path.append(
|
||||
path / Path(base_module_folder) / Path("addons")
|
||||
)
|
||||
elif skip_addon_path(migration_step, path):
|
||||
pass
|
||||
else:
|
||||
addons_path.append(path)
|
||||
|
||||
# return ",".join(addons_path)
|
||||
return ",".join([str(x) for x in addons_path])
|
||||
|
||||
|
||||
def get_odoo_env_path(ctx, odoo_version: dict) -> Path:
|
||||
|
|
@ -78,8 +80,7 @@ def generate_odoo_command(
|
|||
demo: bool,
|
||||
) -> str:
|
||||
# TODO, make it dynamic
|
||||
# addons_path = get_odoo_addons_path(ctx, migration_step)
|
||||
addons_path = "/odoo_env/src/odoo/addons," "/odoo_env/src/odoo/odoo/addons"
|
||||
addons_path = get_odoo_addons_path(ctx, Path("/odoo_env"), migration_step)
|
||||
database_cmd = database and "--database %s" % database or ""
|
||||
update_cmd = update and "--update_%s" % update or ""
|
||||
init_cmd = init and "--init %s" % init or ""
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user