Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] util/modules: force install of new modules #140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
26 changes: 19 additions & 7 deletions src/util/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def _up(table, old, new):
cr.execute("DELETE FROM ir_module_module_dependency WHERE name=%s", [old])
cr.execute("DELETE FROM ir_model_data WHERE model='ir.module.module' AND res_id=%s", [mod_ids[old]])
if state in INSTALLED_MODULE_STATES:
force_install_module(cr, into)
_force_install_module(cr, into)


def force_install_module(cr, module, if_installed=None):
Expand All @@ -486,8 +486,19 @@ def force_install_module(cr, module, if_installed=None):
:param str module: name of the module to install
:param list(str) or None if_installed: only force the install when these modules are
already installed
:return str: the *original* state of the module
KangOl marked this conversation as resolved.
Show resolved Hide resolved
"""
if version_gte("saas~14.5"):
# We must delay until the modules actually exists. They are added by the auto discovery process.
if not if_installed or modules_installed(cr, *if_installed):
ENVIRON["__modules_auto_discovery_force_installs"].add(module)
KangOl marked this conversation as resolved.
Show resolved Hide resolved
else:
_force_install_module(cr, module, if_installed)


def _force_install_module(cr, module, if_installed=None):
# Low level implementation
# Needs the module to exist in the database
_assert_modules_exists(cr, module, *if_installed or ())
subquery = ""
subparams = ()
if if_installed:
Expand Down Expand Up @@ -582,7 +593,7 @@ def force_install_module(cr, module, if_installed=None):
)
for (mod,) in cr.fetchall():
_logger.debug("auto install module %r due to module %r being force installed", mod, module)
force_install_module(cr, mod)
_force_install_module(cr, mod)

# TODO handle module exclusions

Expand Down Expand Up @@ -622,7 +633,7 @@ def new_module_dep(cr, module, new_dep):
if mod_state in INSTALLED_MODULE_STATES:
# Module was installed, need to install all its deps, recursively,
# to make sure the new dep is installed
force_install_module(cr, module)
_force_install_module(cr, module)


def remove_module_deps(cr, module, old_deps):
Expand Down Expand Up @@ -726,7 +737,7 @@ def trigger_auto_install(cr, module):

cr.execute(query, [module, INSTALLED_MODULE_STATES])
if cr.rowcount:
force_install_module(cr, module)
_force_install_module(cr, module)
return True
return False

Expand Down Expand Up @@ -852,6 +863,7 @@ def _force_upgrade_of_fresh_module(cr, module, init, version):
# Low level implementation
# Force module state to be in `to upgrade`.
# Needed for migration script execution. See http://git.io/vnF7f
_assert_modules_exists(cr, module)
cr.execute(
"""
UPDATE ir_module_module
Expand Down Expand Up @@ -917,8 +929,8 @@ def _trigger_auto_discovery(cr):
_set_module_countries(cr, module, countries)
module_auto_install(cr, module, auto_install)

if module in force_installs:
force_install_module(cr, module)
for module in force_installs:
_force_install_module(cr, module)

for module, (init, version) in ENVIRON["__modules_auto_discovery_force_upgrades"].items():
_force_upgrade_of_fresh_module(cr, module, init, version)
Expand Down