跳至内容
菜单
此问题已终结
2 回复
4648 查看

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
3362
0
11月 23
972
1
2月 21
4353
4
7月 20
13371
0
3月 18
3669