[FIX] correct config wizard to not crash if a module is not found
authorChristophe Simonis <chs@openerp.com>
Tue, 11 Sep 2012 11:50:03 +0000 (13:50 +0200)
committerChristophe Simonis <chs@openerp.com>
Tue, 11 Sep 2012 11:50:03 +0000 (13:50 +0200)
bzr revid: chs@openerp.com-20120911115003-8a9a0f8dsoirkx9i

openerp-server
openerp/addons/base/module/module.py
openerp/addons/base/res/res_config.py

index bff23d4..1348d5a 100755 (executable)
@@ -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
 
index 93ad9ce..7aabf80 100644 (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:
index 3f4a052..7556af5 100644 (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_uninstall_ids:
+            ir_module.button_immediate_uninstall(cr, uid, to_uninstall_ids, context=context)
 
-        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_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 {