Browse Source

Merge pull request #172 from hbrunn/8.0-auth_dynamic_groups

[FIX] use correct user when evaluating group condition
pull/237/head
Alexandre Fayolle 9 years ago
parent
commit
e3139ee4f2
  1. 5
      auth_dynamic_groups/model/res_groups.py
  2. 2
      auth_dynamic_groups/model/res_users.py

5
auth_dynamic_groups/model/res_groups.py

@ -33,13 +33,14 @@ class res_groups(models.Model):
'time, you get `user` passed as a browse record')
@api.multi
def eval_dynamic_group_condition(self):
def eval_dynamic_group_condition(self, uid=None):
user = self.env['res.users'].browse([uid]) if uid else self.env.user
result = all(
self.mapped(
lambda this: safe_eval(
this.dynamic_group_condition or 'False',
{
'user': self.env.user,
'user': user.sudo(),
'any': any,
'all': all,
'filter': filter,

2
auth_dynamic_groups/model/res_users.py

@ -43,7 +43,7 @@ class res_users(Model):
{
'groups_id': [
(4, dynamic_group.id)
if dynamic_group.eval_dynamic_group_condition()
if dynamic_group.eval_dynamic_group_condition(uid=uid)
else (3, dynamic_group.id)
for dynamic_group in groups_obj.browse(
cr, SUPERUSER_ID,

Loading…
Cancel
Save