Skip to content
Permalink
Browse files

[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 #31206
  • Loading branch information...
ThanhDodeurOdoo committed Feb 18, 2019
1 parent 8a4fe6d commit d12c993a28b5971dc5bf7dbb88e4b7c606f592b5
Showing with 14 additions and 3 deletions.
  1. +7 −2 addons/mail/static/src/js/chatter.js
  2. +7 −1 addons/mail/static/src/xml/chatter.xml
@@ -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');
});
}
@@ -105,11 +105,17 @@

</t>

<!--
Chatter attachment paperclip button.
@param {boolean} [displayCounter]
@param {integer} [count]
-->
<t t-name="mail.chatter.Attachment.Button">
<button class="btn btn-link o_chatter_button_attachment" title="View all the attachments of the current record">
<span>
<i class="fa fa-paperclip"/>
<span class="o_chatter_attachment_button_count">
<span t-if="displayCounter" class="o_chatter_attachment_button_count">
<t t-esc="count"/>
</span>
</span>

0 comments on commit d12c993

Please sign in to comment.
You can’t perform that action at this time.