diff --git a/auth_dynamic_groups/model/res_groups.py b/auth_dynamic_groups/model/res_groups.py index 7acb8fb4e..cec27fcd6 100644 --- a/auth_dynamic_groups/model/res_groups.py +++ b/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, { - 'user': self.env.user, + 'user': user.sudo(), 'any': any, 'all': all, 'filter': filter, diff --git a/auth_dynamic_groups/model/res_users.py b/auth_dynamic_groups/model/res_users.py index bb875e152..ee96be56b 100644 --- a/auth_dynamic_groups/model/res_users.py +++ b/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,