1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2011 OpenERP S.A (<http://www.openerp.com>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
22 from openerp import SUPERUSER_ID
23 from openerp.osv import osv
24 from openerp.tools.translate import _
27 class mail_mail(osv.Model):
28 """ Update of mail_mail class, to add the signin URL to notifications. """
29 _inherit = 'mail.mail'
31 def _get_partner_access_link(self, cr, uid, mail, partner=None, context=None):
32 """ Generate URLs for links in mails:
33 - partner is not an user: signup_url
34 - partner is an user: fallback on classic URL
38 partner_obj = self.pool.get('res.partner')
39 if partner and not partner.user_ids:
40 contex_signup = dict(context, signup_valid=True)
41 signup_url = partner_obj._get_signup_url_for_action(cr, SUPERUSER_ID, [partner.id],
42 action='mail.action_mail_redirect',
43 model=mail.model, res_id=mail.res_id,
44 context=contex_signup)[partner.id]
45 return ", <span class='oe_mail_footer_access'><small>%(access_msg)s <a style='color:inherit' href='%(portal_link)s'>%(portal_msg)s</a></small></span>" % {
46 'access_msg': _('access directly to'),
47 'portal_link': signup_url,
48 'portal_msg': '%s %s' % (context.get('model_name', ''), mail.record_name) if mail.record_name else _('your messages '),
51 return super(mail_mail, self)._get_partner_access_link(cr, uid, mail, partner=partner, context=context)