diff --git a/newsfragments/version-simplification.misc b/newsfragments/version-simplification.misc new file mode 100644 index 0000000..38e6346 --- /dev/null +++ b/newsfragments/version-simplification.misc @@ -0,0 +1 @@ +Refactor to simplify configuration_version_dependant.py file. diff --git a/odoo_openupgrade_wizard/configuration_version_dependant.py b/odoo_openupgrade_wizard/configuration_version_dependant.py index 55e98e4..e3e6f47 100644 --- a/odoo_openupgrade_wizard/configuration_version_dependant.py +++ b/odoo_openupgrade_wizard/configuration_version_dependant.py @@ -2,35 +2,7 @@ from pathlib import Path from loguru import logger -_ODOO_VERSION_TEMPLATES = [ - { - "version": 8.0, - }, - { - "version": 9.0, - }, - { - "version": 10.0, - }, - { - "version": 11.0, - }, - { - "version": 12.0, - }, - { - "version": 13.0, - }, - { - "version": 14.0, - }, - { - "version": 15.0, - }, - { - "version": 16.0, - }, -] +_ALL_ODOO_VERSIONS = [8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0] def get_version_options(mode: str) -> list: @@ -42,7 +14,7 @@ def get_version_options(mode: str) -> list: Exemple: ['9.0', '10.0', '11.0'] """ - version_options = [str(x["version"]) for x in _ODOO_VERSION_TEMPLATES] + version_options = [str(version) for version in _ALL_ODOO_VERSIONS] if mode == "initial": version_options = version_options[:-1] if mode == "final": @@ -55,12 +27,9 @@ def get_odoo_versions(initial_version: float, final_version: float) -> list: version """ result = [] - for version_template in _ODOO_VERSION_TEMPLATES: - if ( - version_template["version"] >= initial_version - and version_template["version"] <= final_version - ): - result.append(version_template["version"]) + for version in _ALL_ODOO_VERSIONS: + if version >= initial_version and version <= final_version: + result.append(version) return result