From 78d2b87a7879f87e5dbb00337eae1129574c223f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Wed, 9 Nov 2022 10:39:39 +0000 Subject: [PATCH] [FIX] mail: allow uploading same attachment twice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, when uploading an attachment then delete then re-upload attachment again, the reupload was unsuccessful. This happens because it should clear the `` of type `file`, but the condition was wrong and therefore `` was not cleared, thus keeping same value as before so input was not detected as changed. A change on this file input is necessary to detect user interaction file upload. This commit fixes trigger for clearing the `` of type file, so that any file upload is properly detected, including uploading same attachment. Task-3060429 closes odoo/odoo#105465 X-original-commit: 97f445ae15663486d0100d7127287f9ec3d1d4cc Signed-off-by: Alexandre Kühn (aku) --- addons/mail/static/src/models/file_uploader.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/mail/static/src/models/file_uploader.js b/addons/mail/static/src/models/file_uploader.js index 3ea8cbd7fcd..66a7bbcd615 100644 --- a/addons/mail/static/src/models/file_uploader.js +++ b/addons/mail/static/src/models/file_uploader.js @@ -38,13 +38,12 @@ Model({ if (!this.exists()) { return; } - if (this.fileInput && this.fileInput.el) { - this.fileInput.el.value = ''; - } if (this.chatterOwner && !this.chatterOwner.hasAttachmentBox) { this.chatterOwner.openAttachmentBox(); } this.messaging.messagingBus.trigger('o-file-uploader-upload', { files }); + // clear at the end because side-effect of emptying `files` + this.fileInput.value = ''; }, /** * @private