跳至內容
選單
此問題已被標幟
4 回覆
9281 瀏覽次數

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.

相關帖文 回覆 瀏覽次數 活動
2
12月 19
3743
1
3月 18
6617
1
11月 22
7350
0
11月 21
2548
0
8月 20
4572