[MERGE] orm,base: added ir.model introspection OOo report, made orm._get_xml_ids() private (return type incompatible with XML-RPC)
bzr revid: odo@openerp.com-20110118155219-z02i8o5oz0q2vd09
This commit is contained in:
commit
483b7ed193
|
@ -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',
|
||||
|
|
|
@ -1013,6 +1013,7 @@
|
|||
<field name="model"/>
|
||||
<field name="osv_memory"/>
|
||||
<field name="state"/>
|
||||
<field name="modules" colspan="4"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Fields">
|
||||
|
@ -1027,29 +1028,26 @@
|
|||
<field name="state"/>
|
||||
</tree>
|
||||
<form string="Fields Description">
|
||||
<group colspan="4" col="4">
|
||||
<field name="name" select="1"/>
|
||||
<field colspan="4" name="field_description" select="2"/>
|
||||
</group>
|
||||
<field name="name"/>
|
||||
<field name="field_description"/>
|
||||
<field name="state"/>
|
||||
|
||||
<separator string="Properties" colspan="4"/>
|
||||
<group colspan="2" col="2">
|
||||
<separator string="Field Type" colspan="2"/>
|
||||
<field name="ttype" select="2"/>
|
||||
<field name="ttype"/>
|
||||
<field name="relation" attrs="{'required': [('ttype','in',['many2one','one2many','many2many'])],'readonly': [('ttype','!=','one2many'), ('ttype','!=','many2one'), ('ttype','!=','many2many')]}"/>
|
||||
<field name="relation_field" attrs="{'required': [('ttype','=','one2many')], 'readonly': [('ttype','!=','one2many')]}"/>
|
||||
<field name="selection" attrs="{'required': [('ttype','in',['selection','reference'])], 'readonly': [('ttype','not in',['selection','reference'])]}"/>
|
||||
<field name="size" attrs="{'required': [('ttype','in',['char','reference'])], 'readonly': [('ttype','not in',['char','reference'])]}"/>
|
||||
<field name="state"/>
|
||||
<field name="domain" attrs="{'readonly': [('relation','=','')]}"/>
|
||||
</group>
|
||||
|
||||
<group colspan="2" col="2">
|
||||
<separator string="Properties" colspan="2"/>
|
||||
<field name="required" select="2"/>
|
||||
<field name="readonly" select="2"/>
|
||||
<field name="required"/>
|
||||
<field name="readonly"/>
|
||||
<field name="select_level"/>
|
||||
<field name="translate"/>
|
||||
<field name="on_delete" attrs="{'readonly': [('ttype','!=','many2one')]}"/>
|
||||
<field name="modules"/>
|
||||
</group>
|
||||
<separator string="Groups" colspan="4"/>
|
||||
<field name="groups" colspan="4" nolabel="1"/>
|
||||
|
@ -1078,6 +1076,9 @@
|
|||
<page string="Notes">
|
||||
<field colspan="4" name="info" nolabel="1"/>
|
||||
</page>
|
||||
<page string="Views">
|
||||
<field colspan="4" name="view_ids" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
|
@ -1140,7 +1141,7 @@
|
|||
<field name="model_id" attrs="{'readonly': [('state','!=', 'manual')]}"/>
|
||||
<field name="field_description"/>
|
||||
<field name="state"/>
|
||||
</group>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Properties">
|
||||
<group colspan="2" col="2">
|
||||
|
@ -1159,6 +1160,7 @@
|
|||
<field name="select_level"/>
|
||||
<field name="translate"/>
|
||||
<field name="on_delete" attrs="{'readonly': [('ttype','!=','many2one')]}"/>
|
||||
<field name="modules"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Security">
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<report id="report_ir_model_overview"
|
||||
string="Model Overview"
|
||||
model="ir.model"
|
||||
name="ir.model.overview"
|
||||
report_type="sxw"
|
||||
file="base/ir/report/modeloverview.sxw"
|
||||
header="False"
|
||||
/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
Binary file not shown.
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue