Skip to content
Open
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
1 change: 1 addition & 0 deletions src/util/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"__modules_auto_discovery_force_upgrades": {},
"__fix_fk_allowed_cascade": [],
"__no_model_data_delete": {},
"__force_installed_modules": set(),
}

NEARLYWARN = 25 # between info and warning; appear on runbot build page
Expand Down
12 changes: 12 additions & 0 deletions src/util/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ def module_installed(cr, module):
return modules_installed(cr, module)


def module_force_installed(module):
"""
Return whether a module is force installed during the upgrade.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the current implementation we don't know if it was actually installed. It's a set of modules that are going to be attempted to be installed.

I understand that it works for your use case, but either the description or the implementation could be slightly adjusted.

Suggested change
Return whether a module is force installed during the upgrade.
Return whether a module is marked for force install during the upgrade.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it is not the most accurate description, but given that we use module_installed with the same confidence solely based on the state even if the module is yet to be installed to to be updated, i used a similar description

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think the other one should be reworded then, not taken as an example. It's a minimal change, so it doesn't diminish clarity/readability and it's factually wrong when put this way.


:param str module: name of the module to check
:rtype: bool
"""
return module in ENVIRON["__force_installed_modules"]


@_warn_usage_outside_base
def uninstall_module(cr, module):
"""
Expand Down Expand Up @@ -655,6 +665,8 @@ def _force_install_module(cr, module, if_installed=None, reason="it has been exp
states = dict(cr.fetchall())
toinstall = [m for m in states if states[m] == "to install"]

ENVIRON["__force_installed_modules"].update(toinstall)

if module in toinstall:
_logger.info(
"force install of module %r (and its dependencies) because %s%s",
Expand Down