fix(tnc): using get_cached_doc to retrieve template for get_terms_and_conditions and permission checks (#57096)

This commit is contained in:
Diptanil Saha
2026-07-13 16:54:56 +05:30
committed by GitHub
parent 33abc53d7a
commit 9c353741ad

View File

@@ -39,7 +39,10 @@ class TermsandConditions(Document):
def get_terms_and_conditions(template_name: str, doc: str | dict):
doc = frappe.parse_json(doc)
terms = frappe.get_cached_value("Terms and Conditions", template_name, "terms")
tnc = frappe.get_cached_doc("Terms and Conditions", template_name)
tnc.check_permission()
if terms:
return frappe.render_template(terms, doc, restrict_globals=True)
if not tnc.terms:
return
return frappe.render_template(tnc.terms, doc, restrict_globals=True)