From 573ce17d0a4030a29a1d29d81faa10d929ed0b3a Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Mon, 14 Jan 2019 14:54:42 +0000 Subject: [PATCH] [FIX] mail: keep attachments when switching between note and message Start a message mail (respectively note) in the chatter. Attach a file. Switch to note (respectively mail). The attachment is lost. With this commit, we keep the attachments after the switch. opw 1925588 closes odoo/odoo#30197 --- addons/mail/static/src/js/chatter.js | 1 + addons/mail/static/src/js/composer.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/mail/static/src/js/chatter.js b/addons/mail/static/src/js/chatter.js index 33a54ca8fc4..7a3bc8adf9a 100644 --- a/addons/mail/static/src/js/chatter.js +++ b/addons/mail/static/src/js/chatter.js @@ -155,6 +155,7 @@ var Chatter = Widget.extend(chat_mixin, { record_name: this.record_name, default_body: old_composer && old_composer.$input && old_composer.$input.val(), default_mention_selections: old_composer && old_composer.mention_get_listener_selections(), + attachment_ids: (old_composer && old_composer.get('attachment_ids')) || [], }); this.composer.on('input_focused', this, function () { this.composer.mention_set_prefetched_partners(this.mentionSuggestions || []); diff --git a/addons/mail/static/src/js/composer.js b/addons/mail/static/src/js/composer.js index a235eb04d46..b1c178b2aae 100644 --- a/addons/mail/static/src/js/composer.js +++ b/addons/mail/static/src/js/composer.js @@ -389,7 +389,7 @@ var BasicComposer = Widget.extend(chat_mixin, { // Attachments this.AttachmentDataSet = new data.DataSetSearch(this, 'ir.attachment', this.context); this.fileupload_id = _.uniqueId('o_chat_fileupload'); - this.set('attachment_ids', []); + this.set('attachment_ids', options.attachment_ids || []); // Mention this.mention_manager = new MentionManager(this); @@ -449,6 +449,7 @@ var BasicComposer = Widget.extend(chat_mixin, { dom.autoresize(this.$input, {parent: this, min_height: this.options.input_min_height}); // Attachments + this.render_attachments(); $(window).on(this.fileupload_id, this.on_attachment_loaded); this.on("change:attachment_ids", this, this.render_attachments);