[MERGE] forward port branch saas-16 up to b8540eefe3

This commit is contained in:
Christophe Simonis
2017-12-06 11:59:38 +01:00
34 changed files with 228 additions and 55 deletions
+21
View File
@@ -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")