diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-12-04 16:24:24 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-12-04 16:24:24 +0100 |
| commit | 426e269c220073c77894d7ef2fa108f97eadf9b3 (patch) | |
| tree | f7078f83ff6c54f4737633b4f1d45f84da98f265 /odoo/modules/loading.py | |
| parent | be64ba60694a2498e1f023d722775b299554cb85 (diff) | |
| parent | 067a241ea8eee57a7a375a31ac99e67437539141 (diff) | |
[MERGE] forward port branch 10.0 up to 067a241ea8e
Diffstat (limited to 'odoo/modules/loading.py')
| -rw-r--r-- | odoo/modules/loading.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py index e9744844841..950704e45e9 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): _logger.log(25, "All post-tested in %.2fs, %s queries", time.time() - t0, odoo.sql_db.sql_counter - t0_sql) 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") |
