[FIX] portal: set a company for portal without one

The field company_id is not required on the res.partner and is used when the
portal user is created for portal access.
If the partner as no comapny set, the creation crashes (required on the user).

Use system default company, with possibility for overwrite.

Closes #15030
This commit is contained in:
Stefan Rijnhart
2017-01-24 13:39:47 +01:00
committed by Martin Trigaux
parent 94807753e7
commit d0ea652221
+4 -1
View File
@@ -141,7 +141,10 @@ class wizard_user(osv.osv_memory):
user_id = False
# create a user if necessary, and make sure it is in the portal group
if not user:
company_id = wizard_user.partner_id.company_id.id
if wizard_user.partner_id.company_id:
company_id = wizard_user.partner_id.company_id.id
else:
company_id = self.pool['res.company']._company_default_get(cr, uid, 'res.users', context=context)
user_id = self._create_user(cr, SUPERUSER_ID, wizard_user.id, dict(context, company_id=company_id))
else:
user_id = user.id