[IMP] mail: improved link in notification, now of form

Sent from <company> using <openerp:pub>, about <model document_name>, access in <customer portal:partner only>

bzr revid: tde@openerp.com-20140305173610-yw71rophyt3iyfi4
This commit is contained in:
Thibault Delavallée 2014-03-05 18:36:10 +01:00
parent b54b8681a0
commit 0d3d0e9563
3 changed files with 19 additions and 9 deletions

View File

@ -115,8 +115,7 @@ class mail_notification(osv.Model):
Administrator
</p>
<div>
<small>Sent by <a ...>Your Company</a> using <a ...>OpenERP</a>.</small> OR
<small>Sent by Administrator using <a ...>OpenERP</a>.</small>
<small>Sent from <a ...>Your Company</a> using <a ...>OpenERP</a>.</small>
</div>
"""
footer = ""
@ -138,7 +137,7 @@ class mail_notification(osv.Model):
company = "<a style='color:inherit' href='%s'>%s</a>" % (website_url, user.company_id.name)
else:
company = user.company_id.name
sent_by = _('Sent by %(company)s using %(openerp)s.')
sent_by = _('Sent from %(company)s using %(openerp)s')
signature_company = '<small>%s</small>' % (sent_by % {
'company': company,
'openerp': "<a style='color:inherit' href='https://www.openerp.com/'>OpenERP</a>"

View File

@ -148,6 +148,8 @@ class mail_mail(osv.Model):
""" Generate URLs for links in mails:
- partner is an user and has read access to the document: direct link to document with model, res_id
"""
if context is None:
context = {}
if partner and partner.user_ids:
base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
# the parameters to encode for the query and fragment part of url
@ -160,9 +162,9 @@ class mail_mail(osv.Model):
fragment['message_id'] = mail.mail_message_id.id
elif mail.model and mail.res_id:
fragment.update(model=mail.model, res_id=mail.res_id)
url = urljoin(base_url, "?%s#%s" % (urlencode(query), urlencode(fragment)))
return _("""<span class='oe_mail_footer_access'><small>Access your messages and documents <a style='color:inherit' href="%s">in OpenERP</a></small></span>""") % url
return _("""<span class='oe_mail_footer_access'><small>about <a style='color:inherit' href="%s">%s %s</a></small></span>""") % (url, context.get('model_name', ''), mail.record_name)
else:
return None
@ -239,10 +241,19 @@ class mail_mail(osv.Model):
email sending process has failed
:return: True
"""
if context is None:
context = {}
ir_mail_server = self.pool.get('ir.mail_server')
for mail in self.browse(cr, SUPERUSER_ID, ids, context=context):
try:
# TDE note: remove me when model_id field is present on mail.message - done here to avoid doing it multiple times in the sub method
if mail.model:
model_id = self.pool['ir.model'].search(cr, SUPERUSER_ID, [('model', '=', mail.model)], context=context)[0]
model = self.pool['ir.model'].browse(cr, SUPERUSER_ID, model_id, context=context)
else:
model = None
if model:
context['model_name'] = model.name
# handle attachments
attachments = []
for attach in mail.attachment_ids:

View File

@ -39,8 +39,8 @@ class mail_mail(osv.Model):
if partner and not partner.user_ids:
contex_signup = dict(context, signup_valid=True)
signup_url = partner_obj._get_signup_url_for_action(cr, SUPERUSER_ID, [partner.id],
action='login', model=mail.model, res_id=mail.res_id,
context=contex_signup)[partner.id]
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
action='login', model=mail.model, res_id=mail.res_id,
context=contex_signup)[partner.id]
return _("""<span class='oe_mail_footer_access'><small>access %s %s through <a style='color:inherit' href="%s">our Customer Portal</a></small></span>""") % (context.get('model_name', ''), mail.record_name, signup_url)
else:
return super(mail_mail, self)._get_partner_access_link(cr, uid, mail, partner=partner, context=context)