Skip to content

Commit 2e585bf

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 8d07df6 commit 2e585bf

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
@@ -16,6 +16,7 @@
1616
"__modules_to_skip_autoinstall": set(),
1717
"__fix_fk_allowed_cascade": [],
1818
"__no_model_data_delete": {},
19+
"__force_installed_modules": set(),
1920
}
2021

2122
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
@@ -149,6 +149,16 @@ def module_installed(cr, module):
149149
return modules_installed(cr, module)
150150

151151

152+
def module_force_installed(cr, module):
153+
"""
154+
Return whether a module was marked for force installation.
155+
156+
:param str module: name of the module to check
157+
:rtype: bool
158+
"""
159+
return module in ENVIRON["__force_installed_modules"]
160+
161+
152162
@_warn_usage_outside_base
153163
def uninstall_module(cr, module):
154164
"""
@@ -666,6 +676,8 @@ def _force_install_module(cr, module, if_installed=None, reason="it has been exp
666676
states = dict(cr.fetchall())
667677
toinstall = [m for m in states if states[m] == "to install"]
668678

679+
ENVIRON["__force_installed_modules"].update(toinstall)
680+
669681
if module in toinstall:
670682
_logger.info(
671683
"force install of module %r (and its dependencies) because %s%s",

0 commit comments

Comments
 (0)