diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-12-04 20:12:19 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-12-04 20:12:19 +0100 |
| commit | a8d01cbf4ea88f894ff927a6a5424bbb58e630d0 (patch) | |
| tree | b5f52af75dec36eac2bf44941f3c5f7d8ab3a1ed /odoo/modules | |
| parent | 3549688b21eb65e16b9c3f2b6462eb8d8b52cd47 (diff) | |
| parent | a447da75fd6f3c76aa4db80d9a83d5e56fa0854d (diff) | |
[MERGE] forward port branch saas-15 up to a447da75fd6
Diffstat (limited to 'odoo/modules')
| -rw-r--r-- | odoo/modules/__init__.py | 2 | ||||
| -rw-r--r-- | odoo/modules/loading.py | 21 | ||||
| -rw-r--r-- | odoo/modules/registry.py | 6 |
3 files changed, 27 insertions, 2 deletions
diff --git a/odoo/modules/__init__.py b/odoo/modules/__init__.py index 530f81ff5e3..b223df99280 100644 --- a/odoo/modules/__init__.py +++ b/odoo/modules/__init__.py @@ -7,7 +7,7 @@ from . import db, graph, loading, migration, module, registry -from odoo.modules.loading import load_modules +from odoo.modules.loading import load_modules, reset_modules_state from odoo.modules.module import ( adapt_version, diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py index 5952fa499b9..1634e57f711 100644 --- a/odoo/modules/loading.py +++ b/odoo/modules/loading.py @@ -423,3 +423,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") diff --git a/odoo/modules/registry.py b/odoo/modules/registry.py index e0cfb532fd1..3db3dc4e2b7 100644 --- a/odoo/modules/registry.py +++ b/odoo/modules/registry.py @@ -80,7 +80,11 @@ class Registry(Mapping): try: registry.setup_signaling() # This should be a method on Registry - odoo.modules.load_modules(registry._db, force_demo, status, update_module) + try: + odoo.modules.load_modules(registry._db, force_demo, status, update_module) + except Exception: + odoo.modules.reset_modules_state(db_name) + raise except Exception: _logger.exception('Failed to load registry') del cls.registries[db_name] |
