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

i have define a http request like this:

@http.route('/user/register/',type='http',auth='none')

and call   method like this:

issuc = request.env['res.users'].sudo().do_register(uname,upwd)
and do_register method like this:

groups_id = request.env.ref('base.group_user')
values = {
'active': True,
"login": uname,
"password": pwd,
"name": uname,
'groups_id': groups_id,
'company_id': 1,
'partner_id': 1
}
rec = self.sudo().create(values)
Next is the error:

raise ValidationError(_('The chosen company is not in the allowed companies for this user'))

So what is the correct way to create?

아바타
취소
작성자

thanks , i have add company_ids and there another error :

raise exceptions.RedirectWarning(msg, action.id, _('Go to the configuration panel'))

베스트 답변

Try to add the following code in user vals:

'company_ids':  [(6,  0,  [1])]  #  allowed  companies


아바타
취소

Thanks for the answer. Very helpful

관련 게시물 답글 화면 활동
3
2월 24
11243
1
3월 15
7584
3
12월 24
7504
1
8월 24
2106
4
6월 23
3372