[FIX] [IMP] mail_message: adding a non-stored author_avatar field, allowing to display avatars in Chatter messages without having to write some hacks to display the avatars and author images. The field is not stored to avoid issues in a stable version.

bzr revid: tde@openerp.com-20130528143706-3973shwhganlohj8
This commit is contained in:
Thibault Delavallée 2013-05-28 16:37:06 +02:00
parent c4c17fc3d2
commit 2d8f1f4327
2 changed files with 8 additions and 4 deletions

View File

@ -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 = []

View File

@ -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]);