/** @odoo-module **/ import { registry } from "@web/core/registry"; import { openPDFViewer } from "./pdf_preview"; /** * Client action: open an ir.attachment in the PDF preview dialog. * * Python callers return: * { * 'type': 'ir.actions.client', * 'tag': 'fusion_pdf_preview.open_attachment', * 'params': { * 'attachment_id': , * 'title': , // optional, defaults to "Document" * 'model_name': , // optional, for audit log * 'record_ids': , // optional, comma-sep for audit log * 'report_name': , // optional, for audit log * }, * } * * Non-PDF attachments fall back to opening in a new browser tab — the * preview dialog only renders PDF. ZPL labels (text/plain) should NOT * use this action; route those through the direct download act_url. */ registry.category("actions").add( "fusion_pdf_preview.open_attachment", async (env, action) => { const params = action.params || {}; const attachmentId = params.attachment_id; if (!attachmentId) { return; } const title = params.title || "Document"; const url = `/web/content/${attachmentId}`; openPDFViewer(env, url, title, { modelName: params.model_name || "", recordIds: params.record_ids || "", reportName: params.report_name || "", }); } );