Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
9181 มุมมอง

I want to check some conditions on the current login portal user group. I am in the 'group_company_survey_client' group but still, it shows me False value for print the below code.

@http.route(['/survey', '/survey/page/<int:page>'], type='http', auth="user", website=True)
    def survey_page_template(self, page=1, date_begin=None, date_end=None, sortby=None, **kw):
        User = request.env.user
        print('11111111111111111111111',
              User.sudo().user_has_groups('survey_management.group_company_survey_client'))

Thanks in advance


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

If you want to check the group of the current user don't use sudo() :  calling of sudo() before calling user_has_groups() will return the recordset with an updated environment with the admin (superuser) user ID set.

User.user_has_groups('survey_management.group_company_survey_client')

Best regards!

อวตาร
ละทิ้ง
ผู้เขียน

Initially, I'll try with it but getting same 'False' value.

ผู้เขียน

My code work when I used 'request.env['res.users'].browse(request.session.uid)' instead of 'request.env.user'. Don't know what is the difference between them. both show the same value.

Related Posts ตอบกลับ มุมมอง กิจกรรม
Overriding "Product" in odoo 12 website? แก้ไขแล้ว
2
ธ.ค. 19
3660
Website: Method post does not work แก้ไขแล้ว
1
มี.ค. 18
6524
1
พ.ย. 22
7206
0
พ.ย. 21
2465
0
ส.ค. 20
4433