From d615552ae1aac2934368d9adccd84136f191750d Mon Sep 17 00:00:00 2001 From: Preetam Biswal Date: Thu, 9 Apr 2026 11:49:35 +0200 Subject: [PATCH] fix: isolate preview CSS in iframe and negate credit note quantities Preview now renders in an iframe to prevent PEPPOL stylesheet from clashing with ERPNext desk CSS. Parser negates qty and amount for credit notes since PEPPOL uses positive values but ERPNext expects negative on return invoices. --- .../edocument/doctype/edocument/edocument.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/edocument/edocument/doctype/edocument/edocument.js b/edocument/edocument/doctype/edocument/edocument.js index 9eba436..2e6391b 100644 --- a/edocument/edocument/doctype/edocument/edocument.js +++ b/edocument/edocument/doctype/edocument/edocument.js @@ -68,15 +68,16 @@ function show_preview(frm) { freeze_message: __("Generating preview..."), callback: (r) => { if (!r.message) return; - frm.get_field("edocument_preview")?.set_value(r.message); - frm.get_field("edocument_preview")?.$wrapper?.css({ - width: "100%", - padding: "15px", - background: "#fff", - border: "1px solid #e0e0e0", - borderRadius: "4px", - marginTop: "10px", - }); + const field = frm.get_field("edocument_preview"); + if (!field) return; + + // Render preview in an iframe to isolate its CSS from ERPNext + const iframe = ``; + field.set_value(iframe); + field.$wrapper?.css({ width: "100%", marginTop: "10px" }); }, }); }