Skip to content

Commit ec6be07

Browse files
committed
[ADD] modules: check module force install
Add a utility function to check if a given module was force installed during the upgrade. This can be useful when a module is force installed and another module upgrade scripts need to fill in some data for it.
1 parent 7bfebaa commit ec6be07

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/util/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"__modules_auto_discovery_force_upgrades": {},
1616
"__fix_fk_allowed_cascade": [],
1717
"__no_model_data_delete": {},
18+
"__force_installed_modules": set(),
1819
}
1920

2021
NEARLYWARN = 25 # between info and warning; appear on runbot build page

src/util/modules.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,16 @@ def module_installed(cr, module):
148148
return modules_installed(cr, module)
149149

150150

151+
def module_force_installed(module):
152+
"""
153+
Return whether a module is force installed during the upgrade.
154+
155+
:param str module: name of the module to check
156+
:rtype: bool
157+
"""
158+
return module in ENVIRON["__force_installed_modules"]
159+
160+
151161
@_warn_usage_outside_base
152162
def uninstall_module(cr, module):
153163
"""
@@ -655,6 +665,8 @@ def _force_install_module(cr, module, if_installed=None, reason="it has been exp
655665
states = dict(cr.fetchall())
656666
toinstall = [m for m in states if states[m] == "to install"]
657667

668+
ENVIRON["__force_installed_modules"].update(toinstall)
669+
658670
if module in toinstall:
659671
_logger.info(
660672
"force install of module %r (and its dependencies) because %s%s",

0 commit comments

Comments
 (0)