From 7e1b0792da8e4cc330cdffa705871c769b08d3b3 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 26 Jul 2016 12:24:16 +0200 Subject: [PATCH] [FIX] portal: creating a user portal for a partner Steps to reproduce the bug: -Create two companies A and B where A is the parent of B -Admin is in A -Demo is in B -Create a partner P with Demo -Create a user portal for P with Demo Bug: Access error due to the fact that the user portal created for P was created in SUPER_USER with company_ids and company_id set with the same inforamtions as with Admin. Fix: company_ids and company_id must be set with the company of Partner P opw:682930 --- 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 13e2d4830a2..ccef7eb0bd5 100644 --- a/addons/portal/wizard/portal_wizard.py +++ b/addons/portal/wizard/portal_wizard.py @@ -139,7 +139,8 @@ 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: - user_id = self._create_user(cr, SUPERUSER_ID, wizard_user.id, context) + company_id = wizard_user.partner_id.company_id.id + user_id = self._create_user(cr, SUPERUSER_ID, wizard_user.id, dict(context, company_id=company_id)) else: user_id = user.id wizard_user.write({'user_id': user_id}) @@ -167,6 +168,8 @@ class wizard_user(osv.osv_memory): res_users = self.pool.get('res.users') create_context = dict(context or {}, noshortcut=True, no_reset_password=True) # to prevent shortcut creation values = { + 'company_id': context.get('company_id'), + 'company_ids': [(6, 0, [context.get('company_id')])], 'email': extract_email(wizard_user.email), 'login': extract_email(wizard_user.email), 'partner_id': wizard_user.partner_id.id,