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

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
10900
1
3月 15
7219
3
12月 24
6800
1
8月 24
1721
4
6月 23
3138