콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
4680 화면

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
3393
0
11월 23
1005
1
2월 21
4368
4
7월 20
13376
0
3월 18
3679