diff --git a/auth_dynamic_groups/model/res_users.py b/auth_dynamic_groups/model/res_users.py index 8ce916e19..bcfd2d0ad 100644 --- a/auth_dynamic_groups/model/res_users.py +++ b/auth_dynamic_groups/model/res_users.py @@ -40,9 +40,12 @@ class res_users(Model): dynamic_groups = groups_obj.browse( cr, SUPERUSER_ID, groups_obj.search( cr, SUPERUSER_ID, [('is_dynamic', '=', True)])) - cr.execute( - 'delete from res_groups_users_rel where uid=%s and gid in %s', - (uid, tuple(dynamic_groups.ids))) + if dynamic_groups: + cr.execute( + 'delete from res_groups_users_rel ' + 'where uid=%s and gid in %s', + (uid, tuple(dynamic_groups.ids)) + ) for dynamic_group in dynamic_groups: if dynamic_group.eval_dynamic_group_condition(uid=uid): cr.execute(