Skip to content
Snippets Groups Projects
Commit 034b317a authored by Xavier Morel's avatar Xavier Morel
Browse files

[IMP] test_module_operations: make uninstall step more graceful


- process modules to uninstall individually in order to better handle
  their state at that point
- uninstall (and reinstall) modules in provided order, rather than
  whatever postgres feels like (or a sort which might not match what
  we want), mostly useful when uninstalling modules in bulk
- warn if a module is either missing or already uninstalled, rather
  than silently do nothing

closes odoo/odoo#119848

Signed-off-by: default avatarXavier Morel (xmo) <xmo@odoo.com>
parent bee7898a
No related branches found
No related tags found
No related merge requests found
......@@ -157,15 +157,20 @@ def test_cycle(args):
def test_uninstall(args):
""" Tries to uninstall/reinstall one ore more modules"""
domain = [('name', 'in', args.uninstall.split(',')), ('state', '=', 'installed')]
with odoo.registry(args.database).cursor() as cr:
env = odoo.api.Environment(cr, odoo.SUPERUSER_ID, {})
modules = env['ir.module.module'].search(domain)
modules_todo = [(module.id, module.name) for module in modules]
for module_id, module_name in modules_todo:
uninstall(args.database, module_id, module_name)
if args.reinstall and module_name not in INSTALL_BLACKLIST:
for module_name in args.uninstall.split(','):
with odoo.registry(args.database).cursor() as cr:
env = odoo.api.Environment(cr, odoo.SUPERUSER_ID, {})
module = env['ir.module.module'].search([('name', '=', module_name)])
module_id, module_state = module.id, module.state
if module_state == 'installed':
uninstall(args.database, module_id, module_name)
if args.reinstall and module_name not in INSTALL_BLACKLIST:
install(args.database, module_id, module_name)
elif module_state:
_logger.warning("Module %r is not installed", module_name)
else:
_logger.warning("Module %r does not exist", module_name)
def test_standalone(args):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment