diff --git a/addons/portal/data/portal_data.xml b/addons/portal/data/portal_data.xml index ffe12934227..6539d154080 100644 --- a/addons/portal/data/portal_data.xml +++ b/addons/portal/data/portal_data.xml @@ -15,7 +15,7 @@ Dear ${object.user_id.name or ''},
- You have been given access to ${user.company_id.name}'s ${object.wizard_id.portal_id.name}. + You have been given access to ${user.company_id.name}'s portal.
Your login account data is:
diff --git a/addons/portal/wizard/portal_wizard.py b/addons/portal/wizard/portal_wizard.py
index 0c8206c86f6..c96eb169915 100644
--- a/addons/portal/wizard/portal_wizard.py
+++ b/addons/portal/wizard/portal_wizard.py
@@ -29,16 +29,7 @@ class PortalWizard(models.TransientModel):
_name = 'portal.wizard'
_description = 'Portal Access Management'
- def _default_portal(self):
- return self.env['res.groups'].search([('is_portal', '=', True)], limit=1)
-
- portal_id = fields.Many2one('res.groups', domain=[('is_portal', '=', True)], required=True, string='Portal',
- default=_default_portal, help="The portal that users can be added in or removed from.")
- user_ids = fields.One2many('portal.wizard.user', 'wizard_id', string='Users')
- welcome_message = fields.Text('Invitation Message', help="This text is included in the email sent to new users of the portal.")
-
- @api.onchange('portal_id')
- def onchange_portal_id(self):
+ def _default_user_ids(self):
# for each partner, determine corresponding portal.wizard.user records
partner_ids = self.env.context.get('active_ids', [])
contact_ids = set()
@@ -51,13 +42,16 @@ class PortalWizard(models.TransientModel):
contact_ids.add(contact.id)
in_portal = False
if contact.user_ids:
- in_portal = self.portal_id in contact.user_ids[0].groups_id
+ in_portal = self.env.ref('base.group_portal') in contact.user_ids[0].groups_id
user_changes.append((0, 0, {
'partner_id': contact.id,
'email': contact.email,
'in_portal': in_portal,
}))
- self.user_ids = user_changes
+ return user_changes
+
+ user_ids = fields.One2many('portal.wizard.user', 'wizard_id', string='Users',default=_default_user_ids)
+ welcome_message = fields.Text('Invitation Message', help="This text is included in the email sent to new users of the portal.")
@api.multi
def action_apply(self):
@@ -125,9 +119,9 @@ class PortalWizardUser(models.TransientModel):
raise UserError("\n\n".join(error_msg))
for wizard_user in self.sudo().with_context(active_test=False):
- group_portal = wizard_user.wizard_id.portal_id
- if not group_portal.is_portal:
- raise UserError(_('Group %s is not a portal') % group_portal.name)
+
+ group_portal = self.env.ref('base.group_portal')
+ #Checking if the partner has a linked user
user = wizard_user.partner_id.user_ids[0] if wizard_user.partner_id.user_ids else None
# update partner email, if a new one was introduced
if wizard_user.partner_id.email != wizard_user.email:
diff --git a/addons/portal/wizard/portal_wizard_views.xml b/addons/portal/wizard/portal_wizard_views.xml
index 909b822cf8d..5a234ea68ec 100644
--- a/addons/portal/wizard/portal_wizard_views.xml
+++ b/addons/portal/wizard/portal_wizard_views.xml
@@ -15,9 +15,6 @@