İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
5873 Görünümler

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?

Avatar
Vazgeç
Üretici

thanks , i have add company_ids and there another error :

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

En İyi Yanıt

Try to add the following code in user vals:

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


Avatar
Vazgeç

Thanks for the answer. Very helpful

İlgili Gönderiler Cevaplar Görünümler Aktivite
3
Şub 24
11214
1
Mar 15
7580
3
Ara 24
7449
1
Ağu 24
2086
4
Haz 23
3339