From 48880538672c15e5e47629918fc658b414d6f1c7 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 4 Jun 2015 16:50:01 +0200 Subject: [PATCH] [FIX] use correct user when evaluating group condition --- auth_dynamic_groups/model/res_groups.py | 5 +++-- auth_dynamic_groups/model/res_users.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) 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,