diff --git a/bin/addons/base/__openerp__.py b/bin/addons/base/__openerp__.py index cc1ed3778c6..b68e2e909da 100644 --- a/bin/addons/base/__openerp__.py +++ b/bin/addons/base/__openerp__.py @@ -43,6 +43,7 @@ 'ir/wizard/wizard_menu_view.xml', 'ir/ir.xml', 'ir/workflow/workflow_view.xml', + 'ir/report/ir_report.xml', 'module/module_view.xml', 'module/module_data.xml', 'module/module_report.xml', diff --git a/bin/addons/base/ir/ir.xml b/bin/addons/base/ir/ir.xml index cfa76e3853c..99b18dd55c5 100644 --- a/bin/addons/base/ir/ir.xml +++ b/bin/addons/base/ir/ir.xml @@ -1013,6 +1013,7 @@ + @@ -1027,29 +1028,26 @@
- - - - + + + + - - + - - - - - + + + @@ -1078,6 +1076,9 @@ + + + @@ -1140,7 +1141,7 @@ - + @@ -1159,6 +1160,7 @@ + diff --git a/bin/addons/base/ir/ir_model.py b/bin/addons/base/ir/ir_model.py index 57b489f0c5f..25ee8e2cc97 100644 --- a/bin/addons/base/ir/ir_model.py +++ b/bin/addons/base/ir/ir_model.py @@ -42,6 +42,20 @@ def _get_fields_type(self, cr, uid, context=None): field_types.remove(types) return field_types +def _in_modules(self, cr, uid, ids, field_name, arg, context=None): + #pseudo-method used by fields.function in ir.model/ir.model.fields + module_pool = self.pool.get("ir.module.module") + installed_module_ids = module_pool.search(cr, uid, [('state','=','installed')]) + installed_module_names = module_pool.read(cr, uid, installed_module_ids, ['name'], context=context) + installed_modules = set(x['name'] for x in installed_module_names) + + result = {} + xml_ids = osv.osv._get_xml_ids(self, cr, uid, ids) + for k,v in xml_ids.iteritems(): + result[k] = ', '.join(sorted(installed_modules & set(xml_id.split('.')[0] for xml_id in v))) + return result + + class ir_model(osv.osv): _name = 'ir.model' _description = "Objects" @@ -65,6 +79,12 @@ class ir_model(osv.osv): is_osv_mem = self._is_osv_memory(cr, uid, all_model_ids, 'osv_memory', arg=None, context=context) return [('id', 'in', [id for id in is_osv_mem if bool(is_osv_mem[id]) == value])] + def _view_ids(self, cr, uid, ids, field_name, arg, context=None): + models = self.browse(cr, uid, ids) + res = {} + for model in models: + res[model.id] = self.pool.get("ir.ui.view").search(cr, uid, [('model', '=', model.model)]) + return res _columns = { 'name': fields.char('Object Name', size=64, translate=True, required=True), @@ -75,7 +95,9 @@ class ir_model(osv.osv): 'access_ids': fields.one2many('ir.model.access', 'model_id', 'Access'), 'osv_memory': fields.function(_is_osv_memory, method=True, string='In-memory model', type='boolean', fnct_search=_search_osv_memory, - help="Indicates whether this object model lives in memory only, i.e. is not persisted (osv.osv_memory)") + help="Indicates whether this object model lives in memory only, i.e. is not persisted (osv.osv_memory)"), + 'modules': fields.function(_in_modules, method=True, type='char', size=128, string='In modules', help='List of modules in which the object is defined or inherited'), + 'view_ids': fields.function(_view_ids, method=True, type='one2many', obj='ir.ui.view', string='Views'), } _defaults = { @@ -152,6 +174,7 @@ ir_model() class ir_model_fields(osv.osv): _name = 'ir.model.fields' _description = "Fields" + _columns = { 'name': fields.char('Name', required=True, size=64, select=1), 'model': fields.char('Object Name', size=64, required=True, select=1, @@ -180,6 +203,7 @@ class ir_model_fields(osv.osv): 'groups': fields.many2many('res.groups', 'ir_model_fields_group_rel', 'field_id', 'group_id', 'Groups'), 'view_load': fields.boolean('View Auto-Load'), 'selectable': fields.boolean('Selectable'), + 'modules': fields.function(_in_modules, method=True, type='char', size=128, string='In modules', help='List of modules in which the field is defined'), } _rec_name='field_description' _defaults = { diff --git a/bin/addons/base/ir/report/ir_report.xml b/bin/addons/base/ir/report/ir_report.xml new file mode 100644 index 00000000000..3d077f453c8 --- /dev/null +++ b/bin/addons/base/ir/report/ir_report.xml @@ -0,0 +1,16 @@ + + + + + + + + + diff --git a/bin/addons/base/ir/report/modeloverview.sxw b/bin/addons/base/ir/report/modeloverview.sxw new file mode 100644 index 00000000000..83769b93b94 Binary files /dev/null and b/bin/addons/base/ir/report/modeloverview.sxw differ diff --git a/bin/osv/orm.py b/bin/osv/orm.py index e862f2d282e..89b93c41923 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -4190,7 +4190,7 @@ class orm(orm_template): return False return True - def get_xml_ids(self, cr, uid, ids, *args, **kwargs): + def _get_xml_ids(self, cr, uid, ids, *args, **kwargs): """Find out the XML ID(s) of any database record. **Synopsis**: ``_get_xml_ids(cr, uid, ids) -> { 'id': ['module.xml_id'] }`` @@ -4224,7 +4224,7 @@ class orm(orm_template): defaulting to an empty string when there's none (to be usable as a function field). """ - results = self.get_xml_ids(cr, uid, ids) + results = self._get_xml_ids(cr, uid, ids) for k, v in results.items(): if results[k]: results[k] = v[0]