[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:
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user