user = self.env['res.users'].sudo().search(

[('login','=',self.env.user.login)]) desired_group_user = self.env['res.groups'].sudo().search(

[('name','=','desired_group_name')]) query = "select gid from res_groups_users_rel where

gid ={} and uid={}".format(desired_group_user.id,user.id) self.env.cr.execute(query) is_desired_group = self.env.cr.fetchone() desired_user_gr = self.env['res.groups'].sudo().search(

[('id','=',is_desired_group)])

desired_group_name = self.env['res.groups'].search(

[('name','=','desired_group_name')]) is_desired_group = self.env.user.id in desired_group_name.users.ids





Recommend:

In this post you will learn how to check login user group. The need of this post is, to sometime we need to visible invisible some filed on the basis of login user group or we want to perform some action on the basis of login user. To do so we need to get login user group. There are two waysto get login user group. We can use these lines of code on a "button click, onchange of many2one field , computed filed etc".