From 0f98a416e51a26325e157ae98a2cb2aa0adcf340 Mon Sep 17 00:00:00 2001 From: bit-odoo Date: Thu, 2 Dec 2021 06:13:52 +0000 Subject: [PATCH] [FIX] mail: attachment viewer download and print buttons for guest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit: Attachment viewer download and print buttons not working for guests. After this commit: Attachment viewer download and print buttons will work for guests. Task-2664842 closes odoo/odoo#87025 X-original-commit: 191a4b21a446d17a5090481b16f3de56a57f611e Signed-off-by: Alexandre Kühn (aku) --- .../src/components/attachment_viewer/attachment_viewer.js | 2 +- addons/mail/static/src/models/attachment.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) 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 04f2b40c091..838ec03cde9 100644 --- a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js +++ b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js @@ -178,7 +178,7 @@ export class AttachmentViewer extends Component { - + `); printWindow.document.close(); diff --git a/addons/mail/static/src/models/attachment.js b/addons/mail/static/src/models/attachment.js index 9ccc5a25bb2..294157fb350 100644 --- a/addons/mail/static/src/models/attachment.js +++ b/addons/mail/static/src/models/attachment.js @@ -49,7 +49,7 @@ registerModel({ */ download() { const downloadLink = document.createElement('a'); - downloadLink.setAttribute('href', `/web/content/ir.attachment/${this.id}/datas?download=true`); + downloadLink.setAttribute('href', this.downloadUrl); // 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', ''); @@ -140,10 +140,10 @@ registerModel({ */ _computeDownloadUrl() { if (!this.accessToken && this.originThread && this.originThread.model === 'mail.channel') { - return `/mail/channel/${this.originThread.id}/attachment/${this.id}`; + return `/mail/channel/${this.originThread.id}/attachment/${this.id}?download=true`; } - const accessToken = this.accessToken ? `?access_token=${this.accessToken}` : ''; - return `/web/content/ir.attachment/${this.id}/datas${accessToken}`; + const accessToken = this.accessToken ? `access_token=${this.accessToken}&` : ''; + return `/web/content/ir.attachment/${this.id}/datas?${accessToken}download=true`; }, /** * @private