From d0ea652221731df119e60d9032b08fda1e9bf817 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Wed, 11 Jan 2017 17:52:18 +0100 Subject: [PATCH] [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 --- addons/portal/wizard/portal_wizard.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/portal/wizard/portal_wizard.py b/addons/portal/wizard/portal_wizard.py index 27bc21835e5..ebd34af2b02 100644 --- a/addons/portal/wizard/portal_wizard.py +++ b/addons/portal/wizard/portal_wizard.py @@ -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