[ADD] base: list of inherited models on a ir.model
This field is needed to retrieve the list of inherited fields (instead of only the fields of a current model) of a model using domain such as ('model_id', 'in', model.inherited_model_ids) on ir.model.fields
This commit is contained in:
parent
56b3db8219
commit
423a9f3011
|
@ -95,11 +95,21 @@ class ir_model(osv.osv):
|
|||
res[model.id] = self.pool["ir.ui.view"].search(cr, uid, [('model', '=', model.model)])
|
||||
return res
|
||||
|
||||
def _inherited_models(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = dict.fromkeys(ids, [])
|
||||
for model in self.browse(cr, uid, ids, context=context):
|
||||
inherited_models = [model_name for model_name in self.pool[model.model]._inherits]
|
||||
if inherited_models:
|
||||
res[model.id] = self.search(cr, uid, [('model', 'in', inherited_models)], context=context)
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Model Description', translate=True, required=True),
|
||||
'model': fields.char('Model', required=True, select=1),
|
||||
'info': fields.text('Information'),
|
||||
'field_id': fields.one2many('ir.model.fields', 'model_id', 'Fields', required=True, copy=True),
|
||||
'inherited_model_ids': fields.function(_inherited_models, type="many2many", obj="ir.model", string="Inherited models",
|
||||
help="The list of models that extends the current model."),
|
||||
'state': fields.selection([('manual','Custom Object'),('base','Base Object')],'Type', readonly=True),
|
||||
'access_ids': fields.one2many('ir.model.access', 'model_id', 'Access'),
|
||||
'osv_memory': fields.function(_is_osv_memory, string='Transient Model', type='boolean',
|
||||
|
|
Loading…
Reference in New Issue