Skip to content

Commit

Permalink
Make requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Torres committed Nov 17, 2017
1 parent e6f038b commit d1ac158
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion odoo/modules/__init__.py
Expand Up @@ -7,7 +7,7 @@

from . import db, graph, loading, migration, module, registry

from odoo.modules.loading import load_modules, cleanup_modules
from odoo.modules.loading import load_modules, reset_modules_state

from odoo.modules.module import (
adapt_version,
Expand Down
23 changes: 11 additions & 12 deletions odoo/modules/loading.py
Expand Up @@ -433,7 +433,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
cr.close()


def cleanup_modules(db):
def reset_modules_state(db):
"""
Resets modules flagged as "to x" to their original state
"""
Expand All @@ -443,14 +443,13 @@ def cleanup_modules(db):
# installation/upgrade/uninstallation fails, which is the only known case
# for which modules can stay marked as 'to %' for an indefinite amount
# of time
cr = db.cursor()
cr.execute(
"UPDATE ir_module_module SET state=%s WHERE state IN (%s, %s)",
('installed', 'to remove', 'to upgrade')
)
cr.execute(
"UPDATE ir_module_module SET state=%s WHERE state=%s",
('uninstalled', 'to install')
)
cr.commit()
cr.close()
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'"
)
cr.commit()
2 changes: 1 addition & 1 deletion odoo/modules/registry.py
Expand Up @@ -82,7 +82,7 @@ def new(cls, db_name, force_demo=False, status=None, update_module=False):
try:
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
except Exception:
odoo.modules.cleanup_modules(registry._db)
odoo.modules.reset_modules_state(registry._db)
raise
except Exception:
_logger.exception('Failed to load registry')
Expand Down

0 comments on commit d1ac158

Please sign in to comment.