[IMP] use related field on author's image for mail messages
authorMartin Trigaux <mat@openerp.com>
Thu, 18 Apr 2013 07:53:49 +0000 (09:53 +0200)
committerMartin Trigaux <mat@openerp.com>
Thu, 18 Apr 2013 07:53:49 +0000 (09:53 +0200)
bzr revid: mat@openerp.com-20130418075349-l71lf8kdw1er2tzs

addons/mail/mail_message.py
addons/mail/static/src/js/mail.js

index 11dbc55..eb7946b 100644 (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',
index 55b8e4b..fe298b3 100644 (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);
             }