Another way to achieve this with osv.osv and osv.osv_memory is to do like in base_module/ir/ir_model.py @ class ir_model_grid(osv.osv):
Code:
def fields_get(self, cr, uid, fields=None, context=None, read_access=True):
result = super(ir_model_grid, self).fields_get(cr, uid, fields, context)
groups = self.pool.get('res.groups').search(cr, uid, [])
groups_br = self.pool.get('res.groups').browse(cr, uid, groups)
result['group_0'] = {'string': 'All Users','type': 'char','size': 7}
for group in groups_br:
result['group_%d'%group.id] = {'string': '%s'%group.name,'type': 'char','size': 7}
return result
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False):
result = super(ir_model_grid, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar)
groups = self.pool.get('res.groups').search(cr, uid, [])
groups_br = self.pool.get('res.groups').browse(cr, uid, groups)
cols = ['model', 'name']
xml = '''<?xml version="1.0"?>
<%s editable="bottom">
<field name="name" select="1" readonly="1" required="1"/>
<field name="model" select="1" readonly="1" required="1"/>
<field name="group_0"/>
''' % (view_type,)
for group in groups_br:
xml += '''<field name="group_%d"/>''' % (group.id, )
xml += '''</%s>''' % (view_type,)
result['arch'] = xml
result['fields'] = self.fields_get(cr, uid, cols, context)
return result
Thank you to Albert Cervera i Areny for the tip.