Search code examples
python-3.xodoo-12

get user type from res.users in odoo 12



i am trying to get user type from res.users in odoo12.
i did not found a field named sel_groups_1_9_10
here is my code,

current_user = fields.Many2one('res.users','Current User', default=lambda self: self.env.uid)
@api.multi
    def add_followers(self):    
        print(self.current_user.sel_groups_1_9_10)

it generates an error: object res.users has no attribute sel_groups_1_9_10.
how can i get user type?


Solution

  • milan vala

    It is not any field that you can access. It is the group can be classified along with the user of which type. You can check group with this has_group like this :

        self.env.user.has_group('base.group_user') # Check for Internal User
        self.env.user.has_group('base.group_portal') # Check for Portal User
        self.env.user.has_group('base.group_public') # Check for Public User