+ #------------------------------------------------------
+ # mail_mail formatting, tools and send mechanism
+ #------------------------------------------------------
+
+ def _get_partner_access_link(self, cr, uid, mail, partner=None, context=None):
+ """ 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 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
+ query = {'db': cr.dbname}
+ fragment = {
+ 'login': partner.user_ids[0].login,
+ 'action': 'mail.action_mail_redirect',
+ }
+ if mail.notification:
+ 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, "/web?%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
+ else:
+ return None
+