Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
5881 Ansichten

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
Verwerfen
Autor

thanks , i have add company_ids and there another error :

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

Beste Antwort

Try to add the following code in user vals:

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


Avatar
Verwerfen

Thanks for the answer. Very helpful

Verknüpfte Beiträge Antworten Ansichten Aktivität
3
Feb. 24
11223
1
März 15
7582
3
Dez. 24
7462
1
Aug. 24
2091
4
Juni 23
3352