From e8b3e01ccd4b8402f08ff508ab3a856be1a913d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Ra=C3=AFch?= Date: Thu, 12 Dec 2024 11:20:50 +0100 Subject: [PATCH 1/5] [FIX] upgrade_analysis: new modules cannot be merged/renamed in same version Issue: v14 has OCA's 10n_eu_oss (https://github.com/OCA/account-fiscal-rule/tree/14.0/l10n_eu_oss), which is renamed in v15 to l10n_eu_oss_oca (https://github.com/OCA/account-fiscal-rule/tree/15.0/l10n_eu_oss_oca) due to new module Odoo's 10n_eu_oss (https://github.com/odoo/odoo/tree/15.0/addons/l10n_eu_oss). Thus, it doesn't makes sense to have in the coverage file the row `|[new] 10n_eu_oss | |Renamed to l10n_eu_oss_oca|`. --- upgrade_analysis/models/upgrade_analysis.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/upgrade_analysis/models/upgrade_analysis.py b/upgrade_analysis/models/upgrade_analysis.py index 35e44c5be5e..9021c90d429 100644 --- a/upgrade_analysis/models/upgrade_analysis.py +++ b/upgrade_analysis/models/upgrade_analysis.py @@ -550,16 +550,19 @@ def generate_module_coverage_file(self, no_changes_modules): module_descriptions = {} for module in all_modules: status = "" + is_new = False if module in all_local_modules and module in all_remote_modules: module_description = f" {module}" elif module in all_local_modules: module_description = f" |new| {module}" + is_new = True else: module_description = f" |del| {module}" - if module in compare.apriori.merged_modules: + # new modules cannot be merged/renamed in same version + if not is_new and module in compare.apriori.merged_modules: status = f"Merged into {compare.apriori.merged_modules[module]}. " - elif module in compare.apriori.renamed_modules: + elif not is_new and module in compare.apriori.renamed_modules: status = f"Renamed to {compare.apriori.renamed_modules[module]}. " elif module in compare.apriori.renamed_modules.values(): status = "Renamed from {}. ".format( From 06e3c831d885687ed3b3cf2cf2d55407786a9823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Ra=C3=AFch?= Date: Thu, 12 Dec 2024 11:24:45 +0100 Subject: [PATCH 2/5] [FIX] upgrade_analysis: exclude OU modules from coverage file --- upgrade_analysis/models/upgrade_analysis.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/upgrade_analysis/models/upgrade_analysis.py b/upgrade_analysis/models/upgrade_analysis.py index 9021c90d429..2979fcdfd56 100644 --- a/upgrade_analysis/models/upgrade_analysis.py +++ b/upgrade_analysis/models/upgrade_analysis.py @@ -530,7 +530,16 @@ def generate_module_coverage_file(self, no_changes_modules): module_domain = [ ("state", "=", "installed"), - ("name", "not in", ["upgrade_analysis", "openupgrade_records"]), + ( + "name", + "not in", + [ + "upgrade_analysis", + "openupgrade_records", + "openupgrade_scripts", + "openupgrade_framework", + ], + ), ] connection = self.config_id.get_connection() From 640a5e2881861d149b49af214885ea4f667da73b Mon Sep 17 00:00:00 2001 From: Jean-Charles Drubay Date: Tue, 10 May 2022 22:16:31 +0700 Subject: [PATCH 3/5] [FIX] smart button to open the list of analysis from a config --- upgrade_analysis/README.rst | 6 +++--- upgrade_analysis/models/upgrade_comparison_config.py | 8 +++++++- upgrade_analysis/static/description/index.html | 11 ++++------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/upgrade_analysis/README.rst b/upgrade_analysis/README.rst index f82bb3900f0..eeaad060a02 100644 --- a/upgrade_analysis/README.rst +++ b/upgrade_analysis/README.rst @@ -2,7 +2,7 @@ Upgrade Analysis ================ -.. +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! @@ -35,7 +35,7 @@ modules are included in the OpenUpgrade distribution so as a migration script developer you will not usually need to use this tool yourself. If you do need to run your analysis of a custom set of modules, please refer to the documentation here: -https://doc.therp.nl/openupgrade/analysis.html + This module is just a tool, a continuation of the old openupgrade_records in OpenUpgrade in previous versions. It's not @@ -122,7 +122,7 @@ promote its widespread use. Current `maintainers `__: -|maintainer-StefanRijnhart| |maintainer-legalsylvain| +|maintainer-StefanRijnhart| |maintainer-legalsylvain| This module is part of the `OCA/server-tools `_ project on GitHub. diff --git a/upgrade_analysis/models/upgrade_comparison_config.py b/upgrade_analysis/models/upgrade_comparison_config.py index 649866379af..9ba4e2b3ac8 100644 --- a/upgrade_analysis/models/upgrade_comparison_config.py +++ b/upgrade_analysis/models/upgrade_comparison_config.py @@ -93,4 +93,10 @@ def new_analysis(self): def action_show_analysis(self): self.ensure_one() - return {} + return { + "type": "ir.actions.act_window", + "name": "Analyses", + "res_model": "upgrade.analysis", + "view_mode": "tree,form", + "domain": [("id", "in", self.analysis_ids.ids)], + } diff --git a/upgrade_analysis/static/description/index.html b/upgrade_analysis/static/description/index.html index 60c485088a8..ff056be5d75 100644 --- a/upgrade_analysis/static/description/index.html +++ b/upgrade_analysis/static/description/index.html @@ -8,11 +8,10 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ +:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. -Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +274,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: gray; } /* line numbers */ +pre.code .ln { color: grey; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +300,7 @@ span.pre { white-space: pre } -span.problematic, pre.problematic { +span.problematic { color: red } span.section-subtitle { @@ -455,9 +454,7 @@

Contributors

Maintainers

This module is maintained by the OCA.

- -Odoo Community Association - +Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

From 4c8578b0d0f24d04857a443d85948981238b7fea Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Sat, 21 Oct 2023 12:58:03 +0200 Subject: [PATCH 4/5] [IMP] upgrade_analysis: Don't reinstall installed modules If a module is already installed, there's no need of reinstalling it. --- upgrade_analysis/tests/test_module.py | 18 +++++++++--------- .../wizards/upgrade_install_wizard.py | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/upgrade_analysis/tests/test_module.py b/upgrade_analysis/tests/test_module.py index 1fef3325b55..e3e71fbfece 100644 --- a/upgrade_analysis/tests/test_module.py +++ b/upgrade_analysis/tests/test_module.py @@ -8,7 +8,7 @@ class TestUpgradeAnalysis(common.TransactionCase): def setUp(self): super().setUp() self.IrModuleModule = self.env["ir.module.module"] - self.product_module = self.IrModuleModule.search([("name", "=", "product")]) + self.website_module = self.IrModuleModule.search([("name", "=", "website")]) self.sale_module = self.IrModuleModule.search([("name", "=", "sale")]) self.upgrade_analysis = self.IrModuleModule.search( [("name", "=", "upgrade_analysis")] @@ -20,19 +20,19 @@ def test_upgrade_install_wizard(self): wizard.select_odoo_modules() self.assertTrue( - self.product_module.id in wizard.module_ids.ids, + self.website_module.id in wizard.module_ids.ids, "Select Odoo module should select 'product' module", ) - - wizard.select_oca_modules() - self.assertTrue( - self.upgrade_analysis.id in wizard.module_ids.ids, - "Select OCA module should select 'upgrade_analysis' module", - ) + # New patch avoids to reinstall already installed modules, so this will fail + # wizard.select_oca_modules() + # self.assertTrue( + # self.upgrade_analysis.id in wizard.module_ids.ids, + # "Select OCA module should select 'upgrade_analysis' module", + # ) wizard.select_other_modules() self.assertFalse( - self.product_module.id in wizard.module_ids.ids, + self.website_module.id in wizard.module_ids.ids, "Select Other module should not select 'product' module", ) diff --git a/upgrade_analysis/wizards/upgrade_install_wizard.py b/upgrade_analysis/wizards/upgrade_install_wizard.py index 968a28c8be7..7c5f05d37dc 100644 --- a/upgrade_analysis/wizards/upgrade_install_wizard.py +++ b/upgrade_analysis/wizards/upgrade_install_wizard.py @@ -35,7 +35,7 @@ class UpgradeInstallWizard(models.TransientModel): def _module_ids_domain(self, extra_domain=None): domain = [ "&", - ("state", "not in", ["uninstallable", "unknown"]), + ("state", "not in", ["installed", "uninstallable", "unknown"]), ("name", "not in", BLACKLIST_MODULES), ] if extra_domain: From 8cb2a771229b1313207aff26305f60b68373b2e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Ra=C3=AFch?= Date: Thu, 12 Dec 2024 13:06:11 +0100 Subject: [PATCH 5/5] [FIX] upgrade_analysis: migration errors --- upgrade_analysis/compare.py | 9 +++++---- upgrade_analysis/upgrade_log.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/upgrade_analysis/compare.py b/upgrade_analysis/compare.py index f4c251566dd..7024cc59044 100644 --- a/upgrade_analysis/compare.py +++ b/upgrade_analysis/compare.py @@ -480,7 +480,8 @@ def compare_model_sets(old_records, new_records): text += f" [{column['model_type']}]" reprs[module_map(column["module"])].append(text) reprs["general"].append( - f"obsolete model {model} [module module_map(column['module'])]" + f"obsolete model {model} " + f"[module {module_map(column['module'])}]" ) else: moved_module = "" @@ -491,7 +492,7 @@ def compare_model_sets(old_records, new_records): f" (renamed to {model_map(model)}{moved_module})" ) if column["model_type"]: - text += " [column['model_type']]" + text += f" [{column['model_type']}]" reprs[module_map(column["module"])].append(text) reprs["general"].append( f"obsolete model {model} (renamed to {model_map(model)}) " @@ -501,11 +502,11 @@ def compare_model_sets(old_records, new_records): if module_map(column["module"]) != new_models[model]: text = f"model {model} (moved to {new_models[model]})" if column["model_type"]: - text += " [column['model_type']]" + text += f" [{column['model_type']}]" reprs[module_map(column["module"])].append(text) text = f"model {model} (moved from {old_models[model]})" if column["model_type"]: - text += " [column['model_type']]" + text += f" [{column['model_type']}]" for column in copy.copy(new_records): model = column["model"] diff --git a/upgrade_analysis/upgrade_log.py b/upgrade_analysis/upgrade_log.py index a0df0dc62d4..687072771b6 100644 --- a/upgrade_analysis/upgrade_log.py +++ b/upgrade_analysis/upgrade_log.py @@ -213,7 +213,7 @@ def log_xml_id(cr, module, xml_id): if "." not in xml_id: xml_id = f"{module}.{xml_id}" cr.execute( - "SELECT model FROM ir_model_data " "WHERE module = %s AND name = %s", + "SELECT model FROM ir_model_data WHERE module = %s AND name = %s", xml_id.split("."), ) record = cr.fetchone()