Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][FIX] upgrade_analysis: forward ports #3148

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions upgrade_analysis/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Upgrade Analysis
================

..
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
Expand Down Expand Up @@ -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
<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
Expand Down Expand Up @@ -122,7 +122,7 @@ promote its widespread use.

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-StefanRijnhart| |maintainer-legalsylvain|
|maintainer-StefanRijnhart| |maintainer-legalsylvain|

This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/18.0/upgrade_analysis>`_ project on GitHub.

Expand Down
9 changes: 5 additions & 4 deletions upgrade_analysis/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@
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 = ""
Expand All @@ -491,7 +492,7 @@
f" (renamed to {model_map(model)}{moved_module})"
)
if column["model_type"]:
text += " [column['model_type']]"
text += f" [{column['model_type']}]"

Check warning on line 495 in upgrade_analysis/compare.py

View check run for this annotation

Codecov / codecov/patch

upgrade_analysis/compare.py#L495

Added line #L495 was not covered by tests
reprs[module_map(column["module"])].append(text)
reprs["general"].append(
f"obsolete model {model} (renamed to {model_map(model)}) "
Expand All @@ -501,11 +502,11 @@
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']}]"

Check warning on line 505 in upgrade_analysis/compare.py

View check run for this annotation

Codecov / codecov/patch

upgrade_analysis/compare.py#L505

Added line #L505 was not covered by tests
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']}]"

Check warning on line 509 in upgrade_analysis/compare.py

View check run for this annotation

Codecov / codecov/patch

upgrade_analysis/compare.py#L509

Added line #L509 was not covered by tests

for column in copy.copy(new_records):
model = column["model"]
Expand Down
18 changes: 15 additions & 3 deletions upgrade_analysis/models/upgrade_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,16 @@

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()
Expand All @@ -550,16 +559,19 @@
module_descriptions = {}
for module in all_modules:
status = ""
is_new = False

Check warning on line 562 in upgrade_analysis/models/upgrade_analysis.py

View check run for this annotation

Codecov / codecov/patch

upgrade_analysis/models/upgrade_analysis.py#L562

Added line #L562 was not covered by tests
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

Check warning on line 567 in upgrade_analysis/models/upgrade_analysis.py

View check run for this annotation

Codecov / codecov/patch

upgrade_analysis/models/upgrade_analysis.py#L567

Added line #L567 was not covered by tests
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(
Expand Down
8 changes: 7 additions & 1 deletion upgrade_analysis/models/upgrade_comparison_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,10 @@

def action_show_analysis(self):
self.ensure_one()
return {}
return {

Check warning on line 96 in upgrade_analysis/models/upgrade_comparison_config.py

View check run for this annotation

Codecov / codecov/patch

upgrade_analysis/models/upgrade_comparison_config.py#L96

Added line #L96 was not covered by tests
"type": "ir.actions.act_window",
"name": "Analyses",
"res_model": "upgrade.analysis",
"view_mode": "tree,form",
"domain": [("id", "in", self.analysis_ids.ids)],
}
11 changes: 4 additions & 7 deletions upgrade_analysis/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

/*
:Author: David Goodger ([email protected])
: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.
Expand Down Expand Up @@ -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 }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -455,9 +454,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
Expand Down
18 changes: 9 additions & 9 deletions upgrade_analysis/tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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",
)

Expand Down
2 changes: 1 addition & 1 deletion upgrade_analysis/upgrade_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion upgrade_analysis/wizards/upgrade_install_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading