[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
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user