From d12c993a28b5971dc5bf7dbb88e4b7c606f592b5 Mon Sep 17 00:00:00 2001 From: Thanh Dodeur Date: Mon, 18 Feb 2019 14:20:21 +0000 Subject: [PATCH] [FIX] mail: chatter attachments without thread This fix prevents the chatter and attachment box from assuming that there is a mail_thread on the record; Reason: if a chatter is set on a record that doesn't inherit mail_thread, the attachment box will generate errors. closes odoo/odoo#31206 --- addons/mail/static/src/js/chatter.js | 9 +++++++-- addons/mail/static/src/xml/chatter.xml | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/addons/mail/static/src/js/chatter.js b/addons/mail/static/src/js/chatter.js index 330e56b77b4ff..72971fbeee9d7 100644 --- a/addons/mail/static/src/js/chatter.js +++ b/addons/mail/static/src/js/chatter.js @@ -90,6 +90,7 @@ var Chatter = Widget.extend({ this._$topbar = this.$('.o_chatter_topbar'); if(!this._disableAttachmentBox) { this.$('.o_topbar_right_area').append(QWeb.render('mail.chatter.Attachment.Button', { + displayCounter: !!this.fields.thread, count: this.record.data.message_attachment_count || 0, })); } @@ -362,7 +363,9 @@ var Chatter = Widget.extend({ if (this._isAttachmentBoxOpen) { this._fetchAttachments().then(this._openAttachmentBox.bind(this)); } - this.trigger_up('reload', { fieldNames: ['message_attachment_count'] }); + if (this.fields.thread) { + this.trigger_up('reload', { fieldNames: ['message_attachment_count'] }); + } }, /** * @private @@ -490,7 +493,9 @@ var Chatter = Widget.extend({ }) .then(function () { self._reloadAttachmentBox(); - self.fields.thread.removeAttachments([ev.data.attachmentId]); + if (self.fields.thread) { + self.fields.thread.removeAttachments([ev.data.attachmentId]); + } self.trigger_up('reload'); }); } diff --git a/addons/mail/static/src/xml/chatter.xml b/addons/mail/static/src/xml/chatter.xml index 7f8629f1baebc..7fe1eeebd77f8 100644 --- a/addons/mail/static/src/xml/chatter.xml +++ b/addons/mail/static/src/xml/chatter.xml @@ -105,11 +105,17 @@ +