if (this.date && new Date().getTime()-this.date.getTime() < 7*24*60*60*1000) {
this.timerelative = $.timeago(this.date);
}
- if (this.type == 'email' && (!this.author_id || !this.author_id[0])) {
+ if (this.author_avatar) {
+ this.avatar = "data:image/png;base64," + this.author_avatar;
+ } else if (this.type == 'email' && (!this.author_id || !this.author_id[0])) {
this.avatar = ('/mail/static/src/img/email_icon.png');
} else if (this.author_id && this.template != 'mail.compose_message') {
- this.avatar = mail.ChatterUtils.get_image(this.session, 'res.partner', 'image_small', this.author_id[0]);
+ this.avatar = mail.ChatterUtils.get_image(this.session, 'mail.message', 'image_small', this.id);
} else {
this.avatar = mail.ChatterUtils.get_image(this.session, 'res.users', 'image_small', this.session.uid);
}
""" Update of mail_mail class, to add the signin URL to notifications. """
_inherit = 'mail.mail'
- def send_get_mail_body_footer(self, cr, uid, mail, partner=None, context=None):
- """ add a signin link inside the body of a mail.mail
- :param mail: mail.mail browse_record
- :param partner: browse_record of the specific recipient partner
- :return: the resulting body_html
+ 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
"""
+ if context is None:
+ context = {}
partner_obj = self.pool.get('res.partner')
- if partner:
- contex_signup = dict(context or {}, signup_valid=True)
- partner = partner_obj.browse(cr, SUPERUSER_ID, partner.id, context=contex_signup)
- body_footer = _("""<small>Access your messages and documents through <a style='color:inherit' href="%s">our Customer Portal</a></small>""") % partner.signup_url
- # partner is an user: add a link to the document if read access
- if partner.user_ids and mail.model and mail.res_id \
- and self.check_access_rights(cr, partner.user_ids[0].id, 'read', raise_exception=False):
- related_user = partner.user_ids[0]
- try:
- self.pool[mail.model].check_access_rule(cr, related_user.id, [mail.res_id], 'read', context=context)
- url = partner_obj._get_signup_url_for_action(cr, related_user.id, [partner.id], action='', res_id=mail.res_id, model=mail.model, context=context)[partner.id]
- text = _("""<small>Access this document <a style='color:inherit' href="%s">directly in OpenERP</a></small>""") % url
- except except_orm, e:
- pass
- return body_footer
+ 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 _("""<small>Access your messages and documents through <a style='color:inherit' href="%s">our Customer Portal</a></small>""") % signup_url
else:
- return super(mail_mail, self).send_get_mail_body_footer(cr, uid, mail, partner=partner, context=context)
-
+ return super(mail_mail, self)._get_partner_access_link(cr, uid, mail, partner=partner, context=context)
+
+class mail_thread_portal(osv.AbstractModel):
+
+ _inherit = 'mail.thread'
+
+ def get_suggested_thread(self, cr, uid, removed_suggested_threads=None, context=None):
+ """Overwrite to avoid showing suggestions for anonymous users"""
+ anonymous_group = self.pool.get('ir.model.data').get_object(cr, SUPERUSER_ID, 'portal', 'group_anonymous')
+ if uid in [user.id for user in anonymous_group.users]:
+ return []
+ return super(mail_thread_portal, self).get_suggested_thread(cr, uid, removed_suggested_threads, context=context)