[IMP] use related field on author's image for mail messages

bzr revid: mat@openerp.com-20130418075349-l71lf8kdw1er2tzs
This commit is contained in:
Martin Trigaux 2013-04-18 09:53:49 +02:00
parent 67bffc62c4
commit fe8cfcceba
2 changed files with 4 additions and 2 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."),
'image_small': fields.related('author_id', 'image_small', string="Author's Avatar", type="binary"),
'partner_ids': fields.many2many('res.partner', string='Recipients'),
'notified_partner_ids': fields.many2many('res.partner', 'mail_notification',
'message_id', 'partner_id', 'Notified partners',

View File

@ -257,15 +257,16 @@ openerp.mail = function (session) {
/* Convert date, timerelative and avatar in displayable data. */
format_data: function () {
//formating and add some fields for render
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])) {
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);
}