diff --git a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js index fa8088b3254..cd926048172 100644 --- a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js +++ b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js @@ -139,8 +139,7 @@ export class AttachmentViewer extends Component { * @private */ _download() { - const id = this.attachmentViewer.attachment.id; - this.env.services.navigate(`/web/content/ir.attachment/${id}/datas`, { download: true }); + this.attachmentViewer.attachment.download(); } /** diff --git a/addons/mail/static/src/models/attachment/attachment.js b/addons/mail/static/src/models/attachment/attachment.js index a02b9152bfb..abf4c1301ad 100644 --- a/addons/mail/static/src/models/attachment/attachment.js +++ b/addons/mail/static/src/models/attachment/attachment.js @@ -51,7 +51,12 @@ registerModel({ * Send the attachment for the browser to download. */ download() { - this.env.services.navigate(`/web/content/ir.attachment/${this.id}/datas`, { download: true }); + const downloadLink = document.createElement('a'); + downloadLink.setAttribute('href', `/web/content/ir.attachment/${this.id}/datas?download=true`); + // Adding 'download' attribute into a link prevents open a new tab or change the current location of the window. + // This avoids interrupting the activity in the page such as rtc call. + downloadLink.setAttribute('download', ''); + downloadLink.click(); }, /** * Handles click on download icon.