From 7238a82fcb38dbef751b3dddb7f59af79aa8d4a0 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 17 Jun 2022 02:08:01 +0200 Subject: [PATCH] [IMP] search analysis_file.txt --- .../configuration_version_dependant.py | 28 +++++++++++++++++++ odoo_openupgrade_wizard/tools_odoo_module.py | 28 +++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/odoo_openupgrade_wizard/configuration_version_dependant.py b/odoo_openupgrade_wizard/configuration_version_dependant.py index 54d8dde..b7a304a 100644 --- a/odoo_openupgrade_wizard/configuration_version_dependant.py +++ b/odoo_openupgrade_wizard/configuration_version_dependant.py @@ -257,3 +257,31 @@ def get_coverage_relative_path(migration_step: dict) -> (str, Path): ("%.1f" % migration_step["release"]).replace(".", ""), ) ) + + +def get_openupgrade_analysis_files( + odoo_env_path: Path, release: float +) -> dict: + """return a dictionnary of module_name : path, + where module_name is the name of each module of a release + and and path is the path of the migration_analysis.txt file + of the module""" + result = {} + if release < 14.0: + base_name = "openupgrade_analysis.txt" + else: + base_name = "upgrade_analysis.txt" + + files = [ + x + for x in sorted(odoo_env_path.rglob("**/*.txt")) + if x.name == base_name + ] + + for file in files: + if file.parent.parent == "migrations": + module_name = file.parent.parent.parent.name + else: + module_name = file.parent.parent.name + result[module_name] = file + return result diff --git a/odoo_openupgrade_wizard/tools_odoo_module.py b/odoo_openupgrade_wizard/tools_odoo_module.py index d838f6e..6d4e925 100644 --- a/odoo_openupgrade_wizard/tools_odoo_module.py +++ b/odoo_openupgrade_wizard/tools_odoo_module.py @@ -10,6 +10,7 @@ from pygount import SourceAnalysis from odoo_openupgrade_wizard.configuration_version_dependant import ( get_apriori_file_relative_path, get_coverage_relative_path, + get_openupgrade_analysis_files, ) from odoo_openupgrade_wizard.tools_odoo import ( get_odoo_addons_path, @@ -73,6 +74,19 @@ class Analysis(object): for module_version in list(odoo_module.module_versions.values()): module_version.analyse_openupgrade_state(coverage_analysis) + for release in self.all_releases[1:]: + for odoo_module in filter( + lambda x: x.module_type == "odoo", self.modules + ): + odoo_env_path = get_odoo_env_path(ctx, {"release": release}) + openupgrade_analysis_files = get_openupgrade_analysis_files( + odoo_env_path, release + ) + module_version = odoo_module.get_module_version(release) + module_version.analyse_openupgrade_work( + openupgrade_analysis_files + ) + def analyse_missing_module(self): for odoo_module in filter( lambda x: x.module_type != "odoo", self.modules @@ -419,6 +433,9 @@ class OdooModuleVersion(object): self.xml_code = 0 self.javascript_code = 0 self.workload = 0 + self.openupgrade_model_lines = 0 + self.openupgrade_field_lines = 0 + self.openupgrade_xml_lines = 0 def get_last_existing_version(self): versions = list(self.odoo_module.module_versions.values()) @@ -518,6 +535,17 @@ class OdooModuleVersion(object): self.odoo_module.name, False ) + def analyse_openupgrade_work(self, analysis_files): + if self.release == self.odoo_module.analyse.initial_release: + return + analysis_file = analysis_files.get(self.odoo_module.name, False) + if analysis_file: + # TODO + pass + else: + # TODO + pass + def workload_hour_text(self): if not self.workload: return ""