From a95821f9f3ea106456973354cf9071805766e7e2 Mon Sep 17 00:00:00 2001 From: tarteo Date: Fri, 27 Mar 2026 15:01:46 +0100 Subject: [PATCH] [IMP] dms: Clean up attachments after creation of file --- dms/static/src/js/views/dms_file_upload.esm.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dms/static/src/js/views/dms_file_upload.esm.js b/dms/static/src/js/views/dms_file_upload.esm.js index fbccce06e..3dad3878f 100644 --- a/dms/static/src/js/views/dms_file_upload.esm.js +++ b/dms/static/src/js/views/dms_file_upload.esm.js @@ -97,7 +97,15 @@ export function createFileUploadExtension() { throw new Error(attachments.error); } - await this.onUpload(attachments); + await this.onUpload(attachments).finally(() => { + // Delete the attachments once we're done with them + const attachmentIds = attachments.map((a) => a.id); + // If the upload failed, don't waste an unlink call + if (!attachmentIds.length) { + return; + } + this.orm.call("ir.attachment", "unlink", [attachmentIds]); + }); }, async onUpload(attachments) {