[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
|
# See : https://github.com/OCA/openupgradelib/issues/248
|
||||||
# https://github.com/OCA/openupgradelib/issues/288
|
# https://github.com/OCA/openupgradelib/issues/288
|
||||||
_LEGACY_OPENUPGRADELIB = (
|
_LEGACY_OPENUPGRADELIB = (
|
||||||
|
|
@ -98,9 +100,27 @@ def get_odoo_folder(migration_step: dict) -> str:
|
||||||
(./src/odoo, ./src/openupgrade, ...)"""
|
(./src/odoo, ./src/openupgrade, ...)"""
|
||||||
|
|
||||||
if migration_step["action"] == "update":
|
if migration_step["action"] == "update":
|
||||||
return "./src/odoo"
|
return "src/odoo"
|
||||||
|
|
||||||
if migration_step["release"] >= 14.0:
|
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
|
import yaml
|
||||||
|
|
||||||
from odoo_openupgrade_wizard.configuration_version_dependant import (
|
from odoo_openupgrade_wizard.configuration_version_dependant import (
|
||||||
|
get_base_module_folder,
|
||||||
get_odoo_folder,
|
get_odoo_folder,
|
||||||
get_odoo_run_command,
|
get_odoo_run_command,
|
||||||
|
skip_addon_path,
|
||||||
)
|
)
|
||||||
from odoo_openupgrade_wizard.tools_docker import kill_container, run_container
|
from odoo_openupgrade_wizard.tools_docker import kill_container, run_container
|
||||||
|
|
||||||
|
|
||||||
# WIP
|
# 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)
|
odoo_version = get_odoo_version_from_migration_step(ctx, migration_step)
|
||||||
repo_file = get_odoo_env_path(ctx, odoo_version) / Path("repos.yml")
|
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(migration_step)
|
||||||
# base_module_folder = get_base_module_folder(step)
|
|
||||||
stream = open(repo_file, "r")
|
stream = open(repo_file, "r")
|
||||||
data = yaml.safe_load(stream)
|
data = yaml.safe_load(stream)
|
||||||
data = data
|
data = data
|
||||||
|
|
||||||
# addons_path = []
|
addons_path = []
|
||||||
# for key in data.keys():
|
for key in data.keys():
|
||||||
# path = os.path.join(folder, key)
|
path = root_path / Path(key)
|
||||||
# if path.endswith(get_odoo_folder(step)):
|
print(path)
|
||||||
# # Add two folder for odoo folder
|
if str(path).endswith(get_odoo_folder(migration_step)):
|
||||||
# addons_path.append(os.path.join(path, "addons"))
|
# Add two folder for odoo folder
|
||||||
# addons_path.append(
|
addons_path.append(path / Path("addons"))
|
||||||
# os.path.join(path, base_module_folder, "addons")
|
addons_path.append(
|
||||||
# )
|
path / Path(base_module_folder) / Path("addons")
|
||||||
# elif skip_path(step, path):
|
)
|
||||||
# pass
|
elif skip_addon_path(migration_step, path):
|
||||||
# else:
|
pass
|
||||||
# addons_path.append(path)
|
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:
|
def get_odoo_env_path(ctx, odoo_version: dict) -> Path:
|
||||||
|
|
@ -78,8 +80,7 @@ def generate_odoo_command(
|
||||||
demo: bool,
|
demo: bool,
|
||||||
) -> str:
|
) -> str:
|
||||||
# TODO, make it dynamic
|
# TODO, make it dynamic
|
||||||
# addons_path = get_odoo_addons_path(ctx, migration_step)
|
addons_path = get_odoo_addons_path(ctx, Path("/odoo_env"), migration_step)
|
||||||
addons_path = "/odoo_env/src/odoo/addons," "/odoo_env/src/odoo/odoo/addons"
|
|
||||||
database_cmd = database and "--database %s" % database or ""
|
database_cmd = database and "--database %s" % database or ""
|
||||||
update_cmd = update and "--update_%s" % update or ""
|
update_cmd = update and "--update_%s" % update or ""
|
||||||
init_cmd = init and "--init %s" % init or ""
|
init_cmd = init and "--init %s" % init or ""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user