تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
4 الردود
9256 أدوات العرض

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
ديسمبر 19
3726
1
مارس 18
6591
1
نوفمبر 22
7308
0
نوفمبر 21
2507
0
أغسطس 20
4507