diff --git a/addons/hr/models/res_users.py b/addons/hr/models/res_users.py index 8398b543776..68dd63e273e 100644 --- a/addons/hr/models/res_users.py +++ b/addons/hr/models/res_users.py @@ -116,8 +116,13 @@ class User(models.Model): # However, in this case, we want the user to be able to read/write its own data, # even if they are protected by groups. # We make the front-end aware of those fields by sending all field definitions. - if not self.env.user.share: - self = self.sudo() + # Note: limit the `sudo` to the only action of "editing own profile" action in order to + # avoid breaking `groups` mecanism on res.users form view. + context_params = self._context.get('params', {}) + if view_type == 'form' and context_params.get('id') == self.env.user.id and not self.env.user.share: + action_id = self.env['ir.model.data'].xmlid_to_res_id('hr.res_users_action_my', raise_if_not_found=False) + if action_id and context_params.get('action') == action_id: + self = self.sudo() return super(User, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu) @api.multi