[IMP] module loading: iterate on the module graph in deterministic order (by sorting...
[odoo/odoo.git] / openerp / modules / module.py
index 4b97716..7f93427 100644 (file)
@@ -218,6 +218,11 @@ def get_module_resource(module, *args):
         return resource_path
     return False
 
+def get_module_icon(module):
+    iconpath = ['static', 'src', 'img', 'icon.png']
+    if get_module_resource(module, *iconpath):
+        return ('/' + module + '/') + '/'.join(iconpath)
+    return '/base/'  + '/'.join(iconpath)
 
 def load_information_from_description_file(module):
     """
@@ -241,7 +246,7 @@ def load_information_from_description_file(module):
                 'complexity': 'normal',
                 'depends': [],
                 'description': '',
-                'icon': None,
+                'icon': get_module_icon(module),
                 'installable': True,
                 'license': 'AGPL-3',
                 'name': False,
@@ -254,16 +259,9 @@ def load_information_from_description_file(module):
                 'depends data demo test init_xml update_xml demo_xml'.split(),
                 iter(list, None)))
 
-            terp_f = tools.file_open(terp_file)
-            try:
+            with tools.file_open(terp_file) as terp_f:
                 info.update(eval(terp_f.read()))
-            except Exception:
-                logger.notifyChannel('modules', netsvc.LOG_ERROR,
-                    'module %s: exception while evaluating file %s' %
-                    (module, terp_file))
-                raise
-            finally:
-                terp_f.close()
+
             return info
 
     #TODO: refactor the logger in this file to follow the logging guidelines