From 4f453f2ef2be872691b7d1dace490d17e30bf773 Mon Sep 17 00:00:00 2001 From: Hussain Nagaria Date: Fri, 21 Feb 2025 12:57:47 +0530 Subject: [PATCH] fix(print): handle custom format with custom module Co-authored-by: Aman Co-authored-by: Khushbu Co-authored-by: Manya Co-authored-by: Ritika Co-authored-by: Siddharth Co-authored-by: Yashvi --- frappe/www/printview.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/frappe/www/printview.py b/frappe/www/printview.py index ebe382ecc5..0e81e52232 100644 --- a/frappe/www/printview.py +++ b/frappe/www/printview.py @@ -438,21 +438,23 @@ def get_print_format(doctype: str, print_format: "PrintFormat") -> str: # server, find template module = print_format.module or frappe.db.get_value("DocType", doctype, "module") - path = os.path.join( - get_module_path(module, "Print Format", print_format.name), - frappe.scrub(print_format.name) + ".html", - ) - if os.path.exists(path): - with open(path) as pffile: - return pffile.read() - else: + is_custom_module = frappe.get_cached_value("Module Def", module, "custom") + if is_custom_module: if print_format.raw_printing: return print_format.raw_commands if print_format.html: return print_format.html - frappe.throw(_("No template found at path: {0}").format(path), frappe.TemplateNotFoundError) + path = os.path.join( + get_module_path(module, "Print Format", print_format.name), + frappe.scrub(print_format.name) + ".html", + ) + if os.path.exists(path): + with open(path) as pffile: + return pffile.read() + + frappe.throw(_("No template found at path: {0}").format(path), frappe.TemplateNotFoundError) def make_layout(doc: "Document", meta: "Meta", format_data=None) -> list: