Rename groups_id into groups and add groups to the context
This commit is contained in:
1 parent
c8aecb9fdd
commit
9e30d0f747
3 files changed
+14
-10
No files matched your search
+10
-6
@@ -47,7 +47,7 @@ class User(OSV):
|
||||
'active': fields.Boolean('Active'),
|
||||
'action': fields.Many2One('ir.action', 'Home Action'),
|
||||
'menu': fields.Many2One('ir.action', 'Menu Action'),
|
||||
'groups_id': fields.Many2Many('res.group', 'res_group_user_rel',
|
||||
'groups': fields.Many2Many('res.group', 'res_group_user_rel',
|
||||
'uid', 'gid', 'Groups'),
|
||||
'rule_groups': fields.Many2Many('ir.rule.group', 'user_rule_group_rel',
|
||||
'user_id', 'rule_group_id', 'Rules',
|
||||
@@ -75,6 +75,7 @@ class User(OSV):
|
||||
_context_fields = [
|
||||
'language',
|
||||
'timezone',
|
||||
'groups',
|
||||
]
|
||||
|
||||
def __init__(self, pool):
|
||||
@@ -157,12 +158,12 @@ class User(OSV):
|
||||
return res
|
||||
|
||||
def set_preferences(self, cursor, user, values, context=None):
|
||||
values = values.copy()
|
||||
values_clean = values.copy()
|
||||
fields = self._preferences_fields + self._context_fields
|
||||
for field in values:
|
||||
if field not in fields:
|
||||
del values[field]
|
||||
self.write(cursor, 1, user, values, context=context)
|
||||
if field not in fields or field == 'groups':
|
||||
del values_clean[field]
|
||||
self.write(cursor, 1, user, values_clean, context=context)
|
||||
|
||||
def get_preferences_fields_view(self, cursor, user, context=None):
|
||||
res = {}
|
||||
@@ -179,7 +180,10 @@ class User(OSV):
|
||||
arch, fields = self._view_look_dom_arch(cursor,
|
||||
user, doc, context=context)
|
||||
for field in fields:
|
||||
fields[field]['readonly'] = False
|
||||
if field not in ('groups'):
|
||||
fields[field]['readonly'] = False
|
||||
else:
|
||||
fields[field]['readonly'] = True
|
||||
res['arch'] = arch
|
||||
res['fields'] = fields
|
||||
return res
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<field name="signature">Administrator</field>
|
||||
<field name="action" ref="ir.act_menu_tree"/>
|
||||
<field name="menu" ref="ir.act_menu_tree"/>
|
||||
<field name="groups_id" eval="[(6, 0, [ref('group_admin')])]"/>
|
||||
<field name="groups" eval="[(6, 0, [ref('group_admin')])]"/>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="user_view_form">
|
||||
<field name="model">res.user</field>
|
||||
@@ -40,8 +40,8 @@
|
||||
<field name="signature" colspan="4"/>
|
||||
</page>
|
||||
<page string="Security" col="1">
|
||||
<separator name="groups_id"/>
|
||||
<field name="groups_id"/>
|
||||
<separator name="groups"/>
|
||||
<field name="groups"/>
|
||||
<separator name="roles_id"/>
|
||||
<field name="roles_id"/>
|
||||
<separator name="rule_groups"/>
|
||||
|
||||
@@ -66,7 +66,7 @@ def check(cursor, ident, transition, signal):
|
||||
user = ident[0]
|
||||
serv = netsvc.LocalService('object_proxy')
|
||||
user_groups = serv.execute_cr(cursor, user, 'res.user', 'read', user,
|
||||
['groups_id'])['groups_id']
|
||||
['groups'])['groups']
|
||||
res = transition['group'] in user_groups
|
||||
res = res and eval_expr(cursor, ident, transition['condition'])
|
||||
return res
|
||||
Reference in new issue
Block a user