diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-12-04 19:25:51 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-12-04 19:25:51 +0100 |
| commit | a447da75fd6f3c76aa4db80d9a83d5e56fa0854d (patch) | |
| tree | 5d19dd629b4498f16d24d20085aee391b6b06fad /odoo/modules/loading.py | |
| parent | 863fad1b535b05e2fd61b29888f492290c1aa7a5 (diff) | |
| parent | e7d174a1422e2f8bfd849134767d5f43383599b0 (diff) | |
[MERGE] forward port branch saas-14 up to e7d174a1422
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 0f9987f62eb..94b419e3bc7 100644 --- a/odoo/modules/loading.py +++ b/odoo/modules/loading.py @@ -421,3 +421,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") |
