Skip to content

Commit 98a959e

Browse files
committed
[IMP] util/modules: improve logs
The main goal of this patch is to improve the logs. Auto-install modules could get all their dependencies installed as a result of the installation of another module, but not necessarily depend on it. It was wrong to say so in the logs. Before: ``` 2025-08-26 10:13:11,951 159473 INFO test_16_17 odoo.upgrade.util.modules: force install of module 'calendar_sms' (and its dependencies) because it is an auto install module and its dependency 'hr_payroll_holidays' has been force installed ``` After: ``` 2025-08-26 10:14:30,753 160547 INFO test_16_17 odoo.upgrade.util.modules: force install of module 'calendar_sms' (and its dependencies) because it is an auto install module that got all its auto install dependencies installed by the force install of 'hr_payroll_holidays' ``` We take the opportunity to remove direct quey formatting and use `format_query` instead with some other minor improvements. closes #308 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent d94144b commit 98a959e

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/util/modules.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
from .misc import on_CI, str2bool, version_gte
5050
from .models import delete_model
5151
from .orm import env, flush
52-
from .pg import column_exists, table_exists, target_of
52+
from .pg import SQLStr, column_exists, format_query, table_exists, target_of
5353
from .records import ref, remove_group, remove_menus, remove_records, remove_view, replace_record_references_batch
5454

5555
INSTALLED_MODULE_STATES = ("installed", "to install", "to upgrade")
@@ -519,14 +519,15 @@ def force_install_module(cr, module, if_installed=None, reason="it has been expl
519519
:return str: the *new* state of the module
520520
"""
521521
subquery = ""
522-
subparams = ()
522+
params = [module]
523523
if if_installed:
524524
subquery = """AND EXISTS(SELECT 1 FROM ir_module_module
525525
WHERE name IN %s
526526
AND state IN %s)"""
527-
subparams = (tuple(if_installed), INSTALLED_MODULE_STATES)
527+
params.extend((tuple(if_installed), INSTALLED_MODULE_STATES))
528528

529-
cr.execute(
529+
query = format_query(
530+
cr,
530531
"""
531532
WITH RECURSIVE deps (mod_id, dep_name) AS (
532533
SELECT m.id, d.name from ir_module_module_dependency d
@@ -547,9 +548,10 @@ def force_install_module(cr, module, if_installed=None, reason="it has been expl
547548
WHERE m.id = d.mod_id
548549
{0}
549550
RETURNING m.name, m.state
550-
""".format(subquery),
551-
(module,) + subparams,
551+
""",
552+
SQLStr(subquery),
552553
)
554+
cr.execute(query, params)
553555

554556
states = dict(cr.fetchall())
555557
toinstall = [m for m in states if states[m] == "to install"]
@@ -623,7 +625,10 @@ def force_install_module(cr, module, if_installed=None, reason="it has been expl
623625
force_install_module(
624626
cr,
625627
mod,
626-
reason="it is an auto install module and its dependency {!r} has been force installed".format(module),
628+
reason=(
629+
"it is an auto install module that got all its auto install dependencies installed "
630+
"by the force install of {!r}"
631+
).format(module),
627632
)
628633

629634
# TODO handle module exclusions

0 commit comments

Comments
 (0)