[IMP] res_user: we can add 'default_groups_ref' inside the context to set default value for group_id with xml values
bzr revid: chm@openerp.com-20130128133003-rl1xem6hqhlkh621
This commit is contained in:
parent
b7fe7956c5
commit
7d3bf22347
|
@ -778,6 +778,19 @@ class users_view(osv.osv):
|
|||
values['groups_id'] = [(3, id) for id in remove] + [(4, id) for id in add]
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
# add "default_groups_ref" inside the context to set default value for group_id with xml values
|
||||
if context.get("default_groups_ref", None) and isinstance(context.get("default_groups_ref"), list):
|
||||
context['default_groups_id'] = []
|
||||
ir_model_data = self.pool.get('ir.model.data')
|
||||
for group in context.get("default_groups_ref"):
|
||||
group_split = group.split('.')
|
||||
if len(group_split) != 2 or \
|
||||
not group_split[0] or not isinstance(group_split[0], (str, unicode, basestring)) or \
|
||||
not group_split[1] or not isinstance(group_split[1], (str, unicode, basestring)):
|
||||
raise osv.except_osv(_('Invalid context value'), _('Invalid context default_groups_ref value (model.name_id) : "%s"') % group)
|
||||
model_data_ids = ir_model_data.search(cr, SUPERUSER_ID, [('model', '=', 'res.groups'), ('module', '=', group_split[0]), ('name', '=', group_split[1])])
|
||||
context['default_groups_id'] += [group_data['res_id'] for group_data in ir_model_data.read(cr, SUPERUSER_ID, model_data_ids, ['res_id'])]
|
||||
|
||||
group_fields, fields = partition(is_reified_group, fields)
|
||||
fields1 = (fields + ['groups_id']) if group_fields else fields
|
||||
values = super(users_view, self).default_get(cr, uid, fields1, context)
|
||||
|
|
|
@ -125,7 +125,7 @@
|
|||
<field domain="[('usage','=','menu')]" name="menu_id" required="True"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<group string="Email preferences">
|
||||
<field name="signature"/>
|
||||
</group>
|
||||
</page>
|
||||
|
|
Loading…
Reference in New Issue