[FIX] correct config wizard to not crash if a module is not found

bzr revid: chs@openerp.com-20120911115003-8a9a0f8dsoirkx9i
This commit is contained in:
Christophe Simonis
2012-09-11 13:50:03 +02:00
parent a661dd8e53
commit a37175f85a
3 changed files with 16 additions and 12 deletions
+1 -1
View File
@@ -214,7 +214,7 @@ def quit_on_signals():
a = sys.argv[:]
args = [x for i, x in enumerate(a) if x not in strip_args and a[max(i - 1, 0)] not in strip_args]
time.sleep(0.5) # wait end of sockets...
# FIXME http socket cannot be rebind ?!? socket seems to not be freed, even shutdown() is called
os.execv(sys.executable, [sys.executable] + args)
return
+3
View File
@@ -625,6 +625,9 @@ class module(osv.osv):
zimp.load_module(mod.name)
return res
def install_by_names(self, cr, uid, names, context=None):
raise NotImplementedError('# TODO')
def install_from_urls(self, cr, uid, urls, context=None):
tmp = tempfile.mkdtemp()
try:
+12 -11
View File
@@ -467,7 +467,8 @@ class res_config_settings(osv.osv_memory):
groups.append((name, ref(field_group), ref(field.implied_group)))
elif name.startswith('module_') and isinstance(field, fields.boolean):
mod_ids = ir_module.search(cr, uid, [('name', '=', name[7:])])
modules.append((name, ir_module.browse(cr, uid, mod_ids[0], context)))
record = ir_module.browse(cr, uid, mod_ids[0], context) if mod_ids else None
modules.append((name, record))
else:
others.append(name)
@@ -491,7 +492,7 @@ class res_config_settings(osv.osv_memory):
# modules: which modules are installed/to install
for name, module in classified['module']:
res[name] = module.state in ('installed', 'to install', 'to upgrade')
res[name] = module and module.state in ('installed', 'to install', 'to upgrade')
# other fields: call all methods that start with 'get_default_'
for method in dir(self):
@@ -502,9 +503,7 @@ class res_config_settings(osv.osv_memory):
def execute(self, cr, uid, ids, context=None):
ir_values = self.pool.get('ir.values')
ir_model_data = self.pool.get('ir.model.data')
ir_module = self.pool.get('ir.module.module')
res_groups = self.pool.get('res.groups')
classified = self._get_classified_fields(cr, uid, context)
config = self.browse(cr, uid, ids[0], context)
@@ -527,17 +526,19 @@ class res_config_settings(osv.osv_memory):
getattr(self, method)(cr, uid, ids, context)
# module fields: install/uninstall the selected modules
to_install_ids = []
to_install_names = []
to_uninstall_ids = []
for name, module in classified['module']:
if config[name]:
if module.state == 'uninstalled': to_install_ids.append(module.id)
if module and module.state in ('installed', 'to upgrade'):
to_uninstall_ids.append(module.id)
else:
if module.state in ('installed','upgrade'): to_uninstall_ids.append(module.id)
to_install_names.append(name)
if to_install_ids or to_uninstall_ids:
ir_module.button_uninstall(cr, uid, to_uninstall_ids, context=context)
ir_module.button_immediate_install(cr, uid, to_install_ids, context=context)
if to_uninstall_ids:
ir_module.button_immediate_uninstall(cr, uid, to_uninstall_ids, context=context)
if to_install_names:
return ir_module.install_by_names(cr, uid, to_install_names, context=context)
# force client-side reload (update user menu and current view)
return {