summaryrefslogtreecommitdiff
path: root/odoo/modules/loading.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-12-06 12:02:58 +0100
committerChristophe Simonis <chs@odoo.com>2017-12-06 12:02:58 +0100
commit8ef7af6afe54fbd59051bbbce76daadd6fdb0e86 (patch)
treeb21971e972eacc87e198fbc38b48ac9b70d168fc /odoo/modules/loading.py
parent010add290342ae1e2887450a381e0d1f0acd34e5 (diff)
parentf96a797fe6238306ec70d3db013b8a4d348ef181 (diff)
[MERGE] forward port branch 11.0 up to f96a797fe62
Diffstat (limited to 'odoo/modules/loading.py')
-rw-r--r--odoo/modules/loading.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py
index 14a71b49e76..6c4600c8109 100644
--- a/odoo/modules/loading.py
+++ b/odoo/modules/loading.py
@@ -431,3 +431,24 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
finally:
cr.close()
+
+
+def reset_modules_state(db_name):
+ """
+ Resets modules flagged as "to x" to their original state
+ """
+ # Warning, this function was introduced in response to commit 763d714
+ # which locks cron jobs for dbs which have modules marked as 'to %'.
+ # The goal of this function is to be called ONLY when module
+ # installation/upgrade/uninstallation fails, which is the only known case
+ # for which modules can stay marked as 'to %' for an indefinite amount
+ # of time
+ db = odoo.sql_db.db_connect(db_name)
+ with db.cursor() as cr:
+ cr.execute(
+ "UPDATE ir_module_module SET state='installed' WHERE state IN ('to remove', 'to upgrade')"
+ )
+ cr.execute(
+ "UPDATE ir_module_module SET state='uninstalled' WHERE state='to install'"
+ )
+ _logger.warning("Transient module states were reset")