Render HTML Field in core doctype via jinja template - ashish-greycube/help GitHub Wiki

Example

Doctype: Quotation
HTML field name : custom_previous_quotation_details

quotation.js

frappe.ui.form.on("Quotation", {
    onload(frm) {
        if (
            frm.fields_dict["custom_previous_quotation_details"] &&
            frm.is_new() == undefined &&
            frm.doc.__onload && "custom_html_data" in frm.doc.__onload
        ) {
            frm.set_df_property('custom_previous_quotation_details', 'options', frm.doc.__onload.custom_html_data)
        }
    }
})

api.py

def set_previous_quotation_data(self,method):
		template_path = "templates/previous_quotation_table.html"
		html = frappe.render_template(template_path,  dict(doc=self))    
		self.set_onload("custom_html_data", html) 

previous_quotation_table.html

<h1>{{doc.party_name}}</h1>
<h3>{{doc.quotation_to}}</h3>

hooks.py

doctype_js = {"Quotation":"public/js/quotation.js"}
doc_events = {"Quotation":{"onload":"refteck.api.set_previous_quotation_data
⚠️ **GitHub.com Fallback** ⚠️