コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
4671 ビュー

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
3368
0
11月 23
989
1
2月 21
4353
4
7月 20
13373
0
3月 18
3671