Skip to content
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
41 changes: 21 additions & 20 deletions upgrade_analysis/models/upgrade_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
from .. import compare

_logger = logging.getLogger(__name__)
_IGNORE_MODULES = ["openupgrade_records", "upgrade_analysis"]
_IGNORE_MODULES = [
"openupgrade_records",
"upgrade_analysis",
"openupgrade_framework",
"openupgrade_scripts",
]


class UpgradeAnalysis(models.Model):
Expand Down Expand Up @@ -181,7 +186,7 @@ def analyze(self):
remote_model_records, local_model_records
)

affected_modules = sorted(
affected_modules = list(
{
record["module"]
for record in remote_records
Expand All @@ -194,7 +199,7 @@ def analyze(self):
)
if "base" in affected_modules:
try:
pass
from odoo.addons.openupgrade_scripts import apriori # noqa: F401
except ImportError:
_logger.error(
"You are using upgrade_analysis on core modules without "
Expand All @@ -205,21 +210,19 @@ def analyze(self):
)

# reorder and output the result
keys = ["general"] + affected_modules
modules = {
module["name"]: module
for module in self.env["ir.module.module"].search(
[("state", "=", "installed")]
)
}
keys = ["general"] + sorted(
(set(affected_modules) | set(modules.keys())) - set(_IGNORE_MODULES)
)
general_log = ""

no_changes_modules = []

for ignore_module in _IGNORE_MODULES:
if ignore_module in keys:
keys.remove(ignore_module)

for key in keys:
contents = f"---Models in module '{key}'---\n"
if key in res_model:
Expand All @@ -245,8 +248,8 @@ def analyze(self):
if compare.module_map(key) not in modules:
general_log += f"---Probably obsolete module {key}---\n" + contents
continue
if key not in modules:
# no need to log in full log the merged/renamed modules
if key not in modules or key in no_changes_modules:
# no need to log in full log the merged/renamed/unchanged modules
continue
if self.write_files:
error = self._write_file(key, modules[key].installed_version, contents)
Expand All @@ -264,12 +267,13 @@ def analyze(self):
general_log,
"upgrade_general_log.txt",
)

noupdate_modules = []
try:
self.generate_noupdate_changes()
noupdate_modules = self.generate_noupdate_changes()
except Exception as e:
_logger.exception(f"Error generating noupdate changes: {e}")
general_log += "ERROR: error when generating noupdate changes: {e}\n"
no_changes_modules = list(set(no_changes_modules) - set(noupdate_modules))
try:
self.generate_module_coverage_file(no_changes_modules)
except Exception as e:
Expand Down Expand Up @@ -480,6 +484,7 @@ def generate_noupdate_changes(self):
local_record_obj = self.env["upgrade.record"]
local_modules = local_record_obj.list_modules()
all_remote_modules = remote_record_obj.list_modules()
changed_modules = []
for local_module in local_modules:
remote_files = []
remote_modules = []
Expand Down Expand Up @@ -508,33 +513,29 @@ def generate_noupdate_changes(self):
module = self.env["ir.module.module"].search(
[("name", "=", local_module)]
)
changed_modules.append(local_module)
self._write_file(
local_module,
module.installed_version,
diff,
filename="noupdate_changes.xml",
)
return True
return changed_modules

def generate_module_coverage_file(self, no_changes_modules):
self.ensure_one()

module_coverage_file_folder = config.get("module_coverage_file_folder", False)

if not module_coverage_file_folder:
return
return False

module_domain = [
("state", "=", "installed"),
(
"name",
"not in",
[
"upgrade_analysis",
"openupgrade_records",
"openupgrade_scripts",
"openupgrade_framework",
],
_IGNORE_MODULES,
),
]

Expand Down
2 changes: 1 addition & 1 deletion upgrade_analysis/models/upgrade_comparison_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_connection(self):

def new_analysis(self):
self.ensure_one()
analysis = self.env["upgrade.analysis"].create({"config_id": self.id})
analysis = self.env["upgrade.analysis"].create([{"config_id": self.id}])
return {
"name": analysis._description,
"view_mode": "form",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

# ruff: noqa
from odoo import models

Expand All @@ -6,6 +8,8 @@
from ...... import upgrade_log
from .....odoo_patch import OdooPatch

_logger = logging.getLogger(__name__)


class IrModelConstraintPatch(OdooPatch):
target = ir_model.IrModelConstraint
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 @@ -40,7 +40,7 @@ def _module_ids_domain(self, extra_domain=None):
]
)
if extra_domain:
domain = Domain.AND(domain, extra_domain)
domain = Domain.AND([domain, extra_domain])
modules = self.env["ir.module.module"].search(domain)

for start_pattern in BLACKLIST_MODULES_STARTS_WITH:
Expand Down