diff --git a/addons/account/static/src/components/mail_attachments/mail_attachments.js b/addons/account/static/src/components/mail_attachments/mail_attachments.js index 2e845c1132a..e254da4d354 100644 --- a/addons/account/static/src/components/mail_attachments/mail_attachments.js +++ b/addons/account/static/src/components/mail_attachments/mail_attachments.js @@ -55,12 +55,20 @@ export class MailAttachments extends Component { } onFileRemove(deleteId) { - for(let item of this.getValue()){ - if(item.id == deleteId && !item.placeholder){ - this.attachmentIdsToUnlink.add(item.id); + const newValue = []; + for (let item of this.getValue()) { + if (item.id === deleteId) { + if (item.placeholder || item.protect_from_deletion) { + const copyItem = Object.assign({ skip: true }, item); + newValue.push(copyItem); + } else { + this.attachmentIdsToUnlink.add(item.id); + } + } else { + newValue.push(item); } } - this.props.record.update({ [this.props.name]: this.getValue().filter((item) => !this.attachmentIdsToUnlink.has(item.id)) }); + this.props.record.update({ [this.props.name]: newValue }); } async onWillUnmount(){ diff --git a/addons/account/static/src/components/mail_attachments/mail_attachments.xml b/addons/account/static/src/components/mail_attachments/mail_attachments.xml index df4b53ca4f0..698e5fa5946 100644 --- a/addons/account/static/src/components/mail_attachments/mail_attachments.xml +++ b/addons/account/static/src/components/mail_attachments/mail_attachments.xml @@ -3,26 +3,39 @@ - - -