oca-dms/odoo-bringout-oca-dms-dms/dms/static/src/models/attachment_viewer_viewable.esm.js
Ernad Husremovic ae2c6775ba Add oca-dms submodule with 10 DMS modules
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-30 17:46:17 +02:00

30 lines
1.1 KiB
JavaScript

/** @odoo-module **/
import {registerPatch} from "@mail/model/model_core";
registerPatch({
name: "AttachmentViewerViewable",
fields: {
imageUrl: {
compute() {
if (
!this.attachmentOwner.accessToken &&
this.attachmentOwner.originThread &&
this.attachmentOwner.originThread.model === "mail.channel"
) {
return `/mail/channel/${this.attachmentOwner.originThread.id}/image/${this.attachmentOwner.id}`;
}
const accessToken = this.attachmentOwner.accessToken
? `?access_token=${this.attachmentOwner.accessToken}`
: "";
if (
this.attachmentOwner.model_name &&
this.attachmentOwner.model_name === "dms.file"
) {
return `/web/content?id=${this.attachmentOwner.id}&field=content&model=dms.file&filename_field=name&download=false`;
}
return `/web/image/${this.attachmentOwner.id}${accessToken}`;
},
},
},
});