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

Hello fellas here is my question:
Is possible to restrict access to given http route by res.groups.

頭像
捨棄
最佳答案

Hi,

Inside the route you can check whether user belongs to some group or not. Based on this checking you can perform your operations,

See a sample,

@http.route(['/test/page'], type='http', csrf=False, auth="user", website=True)
def redirect_test_page(self, **kwargs):
    user_rec = request.env['res.users'].sudo().search([('id', '=', request.session.uid)])
    if user_rec.has_group('group_external_id'):
        # write the code if user belongs to group
        return request.render('template_id')
    else:
        # code here if user not in group
        return request.render('template_id')

Hope this will give you some idea.

Thanks

頭像
捨棄
作者 最佳答案

Thank you this is what i needed! :)

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
9月 21
3397
0
11月 23
1014
1
2月 21
4377
4
7月 20
13385
0
3月 18
3684