diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 0b6a4aebd18..979d4d7f3b8 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -144,6 +144,7 @@ class mail_message(osv.Model): 'author_id': fields.many2one('res.partner', 'Author', select=1, ondelete='set null', help="Author of the message. If not set, email_from may hold an email address that did not match any partner."), + 'author_avatar': fields.related('author_id', 'image_small', type="binary", string="Author's Avatar"), 'partner_ids': fields.many2many('res.partner', string='Recipients'), 'notified_partner_ids': fields.many2many('res.partner', 'mail_notification', 'message_id', 'partner_id', 'Notified partners', @@ -277,7 +278,7 @@ class mail_message(osv.Model): } if starred: values['read'] = False - + notif_ids = notification_obj.search(cr, uid, domain, context=context) # all message have notifications: already set them as (un)starred @@ -384,6 +385,7 @@ class mail_message(osv.Model): 'parent_id': parent_id, 'is_private': is_private, 'author_id': False, + 'author_avatar': message.author_avatar, 'is_author': False, 'partner_ids': [], 'vote_nb': vote_nb, @@ -514,7 +516,6 @@ class mail_message(osv.Model): message_unload_ids = message_unload_ids if message_unload_ids is not None else [] if message_unload_ids: domain += [('id', 'not in', message_unload_ids)] - notification_obj = self.pool.get('mail.notification') limit = limit or self._message_read_limit message_tree = {} message_list = [] diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 5143c7cc1fe..2cd9c7c077d 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -219,6 +219,7 @@ openerp.mail = function (session) { this.type = datasets.type || false, this.subtype = datasets.subtype || false, this.is_author = datasets.is_author || false, + this.author_avatar = datasets.author_avatar || false, this.is_private = datasets.is_private || false, this.subject = datasets.subject || false, this.name = datasets.name || false, @@ -260,8 +261,10 @@ openerp.mail = function (session) { this.date = this.date ? session.web.str_to_datetime(this.date) : false; 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]);