From f5acf714b089bd159265fcf48463da1206cb1fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Fri, 26 Mar 2021 13:52:21 +0000 Subject: [PATCH] [FIX] mail: no traceback on uploading attachment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-2486731 closes odoo/odoo#68431 X-original-commit: fb713f58b20835bd9bc5257f87817628ff1cf69a Signed-off-by: Sébastien Theys (seb) --- .../components/file_uploader/file_uploader.js | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/addons/mail/static/src/components/file_uploader/file_uploader.js b/addons/mail/static/src/components/file_uploader/file_uploader.js index 7907d81638b..e080c97c466 100644 --- a/addons/mail/static/src/components/file_uploader/file_uploader.js +++ b/addons/mail/static/src/components/file_uploader/file_uploader.js @@ -58,11 +58,12 @@ class FileUploader extends Component { //-------------------------------------------------------------------------- /** + * @deprecated * @private * @param {Object} fileData * @returns {mail.attachment} */ - _createAttachment(fileData) { + _createAttachment(fileData) { return this.env.models['mail.attachment'].create(Object.assign( {}, fileData, @@ -91,11 +92,16 @@ class FileUploader extends Component { */ _createUploadingAttachments(files) { for (const file of files) { - this._createAttachment({ - filename: file.name, - isUploading: true, - name: file.name - }); + this.env.models['mail.attachment'].create( + Object.assign( + { + filename: file.name, + isUploading: true, + name: file.name + }, + this.props.newAttachmentExtraData + ), + ); } } /** @@ -180,13 +186,18 @@ class FileUploader extends Component { // Without this the useStore selector of component could be not called // E.g. in attachment_box_tests.js await new Promise(resolve => setTimeout(resolve)); - const attachment = this._createAttachment({ - filename, - id, - mimetype, - name, - size, - }); + const attachment = this.env.models['mail.attachment'].insert( + Object.assign( + { + filename, + id, + mimetype, + name, + size, + }, + this.props.newAttachmentExtraData + ), + ); this.trigger('o-attachment-created', { attachment }); } }