2012-09-12 15:53:00 +00:00
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2011 OpenERP S.A (<http://www.openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
2012-12-12 12:55:18 +00:00
from openerp import SUPERUSER_ID
2012-11-21 10:04:34 +00:00
from openerp . osv import osv
from openerp . tools . translate import _
2012-09-12 15:53:00 +00:00
2012-12-12 12:55:18 +00:00
2012-10-01 09:14:41 +00:00
class mail_mail ( osv . Model ) :
""" Update of mail_mail class, to add the signin URL to notifications. """
_inherit = ' mail.mail '
2012-09-12 15:53:00 +00:00
2013-04-17 12:22:25 +00:00
def _get_partner_access_link ( self , cr , uid , mail , partner = None , context = None ) :
""" Generate URLs for links in mails:
- partner is not an user : signup_url
- partner is an user : fallback on classic URL
2012-09-12 15:53:00 +00:00
"""
2013-05-21 15:26:57 +00:00
if context is None :
context = { }
2013-01-04 11:32:41 +00:00
partner_obj = self . pool . get ( ' res.partner ' )
2013-04-17 12:22:25 +00:00
if partner and not partner . user_ids :
2013-05-21 15:26:57 +00:00
contex_signup = dict ( context , signup_valid = True )
signup_url = partner_obj . _get_signup_url_for_action ( cr , SUPERUSER_ID , [ partner . id ] ,
2014-03-11 20:53:37 +00:00
model = mail . model , res_id = mail . res_id ,
2013-05-21 15:26:57 +00:00
context = contex_signup ) [ partner . id ]
2013-12-19 13:31:44 +00:00
return _ ( """ <span class= ' oe_mail_footer_access ' ><small>Access your messages and documents through <a style= ' color:inherit ' href= " %s " >our Customer Portal</a></small></span> """ ) % signup_url
2013-04-17 12:22:25 +00:00
else :
return super ( mail_mail , self ) . _get_partner_access_link ( cr , uid , mail , partner = partner , context = context )