From 3f9cb89611e7222207f62c4fa6f7d90eba9ef7cd Mon Sep 17 00:00:00 2001 From: Ejaaz Khan Date: Mon, 3 Mar 2025 17:34:47 +0530 Subject: [PATCH] fix: template error on custom print format --- frappe/www/printview.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/frappe/www/printview.py b/frappe/www/printview.py index 8ace8a9e71..a1ae6a7b33 100644 --- a/frappe/www/printview.py +++ b/frappe/www/printview.py @@ -438,19 +438,20 @@ def get_print_format(doctype: str, print_format: "PrintFormat") -> str: module = print_format.module or frappe.db.get_value("DocType", doctype, "module") 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 - 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() + if not is_custom_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() + + 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)