fix: template error on custom print format

This commit is contained in:
Ejaaz Khan 2025-03-03 17:34:47 +05:30
parent a23b790ccb
commit 3f9cb89611

View file

@ -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)