- Click to create a new portal. -
- A portal helps defining specific views and rules for a group of - users (the portal group). A portal menu, widgets and specific - groups may be assigned to the portal's users. -
-%s' % body, + 'state': 'outgoing', } - body_data.update(subject_data) - email_from = user.email - email_to = portal_user.email - subject = _(WELCOME_EMAIL_SUBJECT) % subject_data - body = _(WELCOME_EMAIL_BODY) % body_data - mail_id = mail_mail.create(cr, uid, { - 'email_from': email_from , - 'email_to': email_to, - 'subject': subject, - 'state': 'outgoing', - 'body_html': '
%s' % body}, context=ctx) - return mail_id - - def create_new_user(self, cr, uid, portal_user, context=None): - res_user = self.pool.get('res.users') - portal = portal_user.wizard_id.portal_id - partner = portal_user.partner_id - action_id = portal.home_action_id and portal.home_action_id.id or False - value = { - 'name': portal_user.name, - 'login': portal_user.email, - 'password': random_password(), - 'email': portal_user.email, - 'lang': portal_user.lang, - 'share': True, - 'action_id': action_id, - 'partner_id': partner.id, - 'groups_id': [(6, 0, [])], - } - user_id = res_user.create(cr, ROOT_UID, value, context=context) - portal_user.write({'user_id': user_id}) - self.send_email(cr, uid, portal_user, user_id, context=context) - return user_id - - def link_portal_user(self, cr, uid, portal_id, user_id, context=None): - res_groups = self.pool.get('res.groups') - portal = res_groups.browse(cr, uid, portal_id, context=context) - portal_user_ids = [u.id for u in portal.users] - if user_id not in portal_user_ids: - return portal.write({'users': [(4, user_id)]}, context=context) - if user_id in portal_user_ids: - return False - - def unlink_portal_user(self, cr, uid, portal_id, user_id, context=None): - res_groups = self.pool.get('res.groups') - return res_groups.write(cr, uid, [portal_id], {'users': [(3, user_id)]}, context=context) - - def unlink_user(self, cr, uid, user_id, context=None): - #TODO: search portal groups - res_user = self.pool.get('res.users') - user = res_user.browse(cr, uid, user_id, context=context) - if not user.groups_id: - user.unlink(context=context) - return True - - - def manage_portal_access(self, cr, uid, ids, context=None): - res_user = self.pool.get('res.users') - for portal_user in self.browse(cr, uid, ids, context=context): - portal = portal_user.wizard_id.portal_id - user_id = portal_user.user_id and portal_user.user_id.id - if not user_id: - user_ids = res_user.search(cr, uid, [('login','=',portal_user.email)]) - user_id = user_ids and user_ids[0] or False - - if not user_id: - user_id = self.create_new_user(cr, uid, portal_user, context=context) - linked = self.link_portal_user(cr, uid, portal.id, user_id, context=context) - #unlink existing user into portal - if not linked and not portal_user.has_portal_user: - self.unlink_portal_user(cr, uid, portal.id, user_id, context=context) - #drop user if it does not has any access in any portal. - self.unlink_user(cr, uid, user_id, context=context) - return True -wizard_user() + return mail_mail.create(cr, uid, mail_values, context=main_context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/portal/wizard/portal_wizard_view.xml b/addons/portal/wizard/portal_wizard_view.xml index 7a81def67b0..e6d7901e2aa 100644 --- a/addons/portal/wizard/portal_wizard_view.xml +++ b/addons/portal/wizard/portal_wizard_view.xml @@ -5,7 +5,7 @@
%s' % body, 'state': 'outgoing', } - return mail_mail.create(cr, uid, mail_values, context=main_context) + return mail_mail.create(cr, uid, mail_values, context=this_context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From bcab2e061e15671374244dc475074244f57e5af6 Mon Sep 17 00:00:00 2001 From: Raphael Collet