This commit is contained in:
Bhavesh Heliconia 2025-06-24 19:00:20 +00:00 committed by GitHub
commit fbeea792c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,16 +1,16 @@
/** @odoo-module **/ /** @odoo-module **/
/* eslint-disable no-undef */
import AttachmentPreviewWidget from "../../attachmentPreviewWidget.esm"; import AttachmentPreviewWidget from "../../attachmentPreviewWidget.esm";
import FormRenderer from "web.FormRenderer"; import FormRenderer from "web.FormRenderer";
import {registerInstancePatchModel} from "@mail/model/model_core"; import {registerInstancePatchModel} from "@mail/model/model_core";
odoo.define("attachment_preview.attachment_card", function (require) { var rpc = require("web.rpc");
var rpc = require("web.rpc");
var chatterpreviewableAttachments = []; var chatterpreviewableAttachments = [];
var active_attachment_id = 0; var active_attachment_id = 0;
var first_click = true; var first_click = true;
FormRenderer.include({ FormRenderer.include({
custom_events: _.extend({}, FormRenderer.prototype.custom_events, { custom_events: _.extend({}, FormRenderer.prototype.custom_events, {
onAttachmentPreview: "_onAttachmentPreview", onAttachmentPreview: "_onAttachmentPreview",
}), }),
@ -58,9 +58,9 @@ odoo.define("attachment_preview.attachment_card", function (require) {
first_click = true; first_click = true;
this.showAttachmentPreviewWidget(first_click); this.showAttachmentPreviewWidget(first_click);
}, },
}); });
function canPreview(extension) { function canPreview(extension) {
return ( return (
$.inArray(extension, [ $.inArray(extension, [
"odt", "odt",
@ -75,14 +75,9 @@ odoo.define("attachment_preview.attachment_card", function (require) {
"ots", "ots",
]) > -1 ]) > -1
); );
} }
function getUrl( function getUrl(attachment_id, attachment_url, attachment_extension, attachment_title) {
attachment_id,
attachment_url,
attachment_extension,
attachment_title
) {
var url = ""; var url = "";
if (attachment_url) { if (attachment_url) {
if (attachment_url.slice(0, 21) === "/web/static/lib/pdfjs") { if (attachment_url.slice(0, 21) === "/web/static/lib/pdfjs") {
@ -115,9 +110,9 @@ odoo.define("attachment_preview.attachment_card", function (require) {
"?model%3Dir.attachment"; "?model%3Dir.attachment";
return url; return url;
} }
registerInstancePatchModel( registerInstancePatchModel(
"mail.attachment_card", "mail.attachment_card",
"attachment_preview/static/src/js/models/attachment_card/attachment_card.js", "attachment_preview/static/src/js/models/attachment_card/attachment_card.js",
{ {
@ -261,5 +256,4 @@ odoo.define("attachment_preview.attachment_card", function (require) {
}); });
}, },
} }
); );
});