Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
5892 มุมมอง

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
Can't create users in odoo 8.0 แก้ไขแล้ว
3
ก.พ. 24
11228
1
มี.ค. 15
7584
3
ธ.ค. 24
7480
1
ส.ค. 24
2099
4
มิ.ย. 23
3358