[FIX] mail: attachment viewer download and print buttons for guest

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) <aku@odoo.com>
This commit is contained in:
bit-odoo
2022-03-23 21:11:06 +01:00
committed by Alexandre Kühn
parent 3de3573f1e
commit 0f98a416e5
2 changed files with 5 additions and 5 deletions
@@ -178,7 +178,7 @@ export class AttachmentViewer extends Component {
</script>
</head>
<body onload='onloadImage()'>
<img src="${this.attachmentViewer.attachment.defaultSource}" alt=""/>
<img src="${this.attachmentViewer.imageUrl}" alt=""/>
</body>
</html>`);
printWindow.document.close();
+4 -4
View File
@@ -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