diff --git a/odoo_openupgrade_wizard/cli.py b/odoo_openupgrade_wizard/cli.py index 5bf4b2d..4119203 100644 --- a/odoo_openupgrade_wizard/cli.py +++ b/odoo_openupgrade_wizard/cli.py @@ -106,7 +106,6 @@ def main(ctx, env_folder, filestore_folder, log_level): with open(config_file_path) as file: config = yaml.safe_load(file) ctx.obj["config"] = config - file.close() elif ctx.invoked_subcommand != "init": raise diff --git a/odoo_openupgrade_wizard/cli_generate_module_analysis.py b/odoo_openupgrade_wizard/cli_generate_module_analysis.py index b8183f2..2750ce8 100644 --- a/odoo_openupgrade_wizard/cli_generate_module_analysis.py +++ b/odoo_openupgrade_wizard/cli_generate_module_analysis.py @@ -78,7 +78,7 @@ def generate_module_analysis(ctx, step, database, modules): database=initial_database, detached_container=True, ) - # # INITIAL : install modules to analyse and generate records + # INITIAL : install modules to analyse and generate records initial_instance = OdooInstance(ctx, initial_database) initial_modules = ( modules @@ -112,7 +112,7 @@ def generate_module_analysis(ctx, step, database, modules): links={initial_container.name: odoo_initial_host_name}, ) - # # FINAL : install modules to analyse and generate records + # FINAL : install modules to analyse and generate records final_instance = OdooInstance( ctx, final_database, diff --git a/odoo_openupgrade_wizard/cli_init.py b/odoo_openupgrade_wizard/cli_init.py index f7ba62d..bd94cd3 100644 --- a/odoo_openupgrade_wizard/cli_init.py +++ b/odoo_openupgrade_wizard/cli_init.py @@ -82,28 +82,28 @@ def init( ] # Add all upgrade steps - count = 2 + step_nbr = 2 for odoo_version in odoo_versions[1:]: steps.append( { - "name": count, + "name": step_nbr, "action": "upgrade", "release": odoo_version["release"], "complete_name": "step_%s__upgrade__%s" - % (str(count).rjust(2, "0"), odoo_version["release"]), + % (str(step_nbr).rjust(2, "0"), odoo_version["release"]), } ) - count += 1 + step_nbr += 1 # add final update step if len(odoo_versions) > 1: steps.append( { - "name": count, + "name": step_nbr, "action": "update", "release": odoo_versions[-1]["release"], "complete_name": "step_%s__update__%s" - % (str(count).rjust(2, "0"), odoo_versions[-1]["release"]), + % (str(step_nbr).rjust(2, "0"), odoo_versions[-1]["release"]), } ) diff --git a/odoo_openupgrade_wizard/cli_options.py b/odoo_openupgrade_wizard/cli_options.py index 8af828e..2846b1a 100644 --- a/odoo_openupgrade_wizard/cli_options.py +++ b/odoo_openupgrade_wizard/cli_options.py @@ -82,8 +82,9 @@ def get_migration_step_from_options(ctx, step_arg): for migration_step in ctx.obj["config"]["migration_steps"]: if migration_step["name"] == step: return migration_step - # TODO, improve exception - raise Exception + raise ValueError( + "No migration step found in configuration for step %s" % step_arg + ) def get_migration_steps_from_options(ctx, first_step_arg, last_step_arg): @@ -99,7 +100,11 @@ def get_migration_steps_from_options(ctx, first_step_arg, last_step_arg): for migration_step in ctx.obj["config"]["migration_steps"]: if migration_step["name"] in list(range(first_step, last_step + 1)): result.append(migration_step.copy()) - if not result: - # TODO, improve exception - raise Exception - return result + if result: + return result + + raise ValueError( + "Unable to define steps in configuration" + " from options. (first step %s ; last step %s)" + % (first_step_arg, last_step_arg) + ) diff --git a/odoo_openupgrade_wizard/configuration_version_dependant.py b/odoo_openupgrade_wizard/configuration_version_dependant.py index 3e1df4d..321608a 100644 --- a/odoo_openupgrade_wizard/configuration_version_dependant.py +++ b/odoo_openupgrade_wizard/configuration_version_dependant.py @@ -112,8 +112,10 @@ def get_base_module_folder(migration_step: dict) -> str: 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 a boolean to indicate if the addon_path should be + remove (during the generation of the addons_path). + Note : if repo.yml contains both odoo and openupgrade repo + we skip one of them (before the V14 refactoring)""" return ( str(path).endswith("/src/odoo") or str(path).endswith("src/openupgrade")