Wednesday, 9 November 2016

Extend erpnext public js funtion

Extend erpnext public js funtion

Templating in ERPNext:


1) Add your js file in your app`s public and write your code, for over write any function of
2) other app`s public js.
3) add you file path in your app build.json
4) bench build

$.extend(erpnext.utils, {
render_address_and_contact: function(frm) {
// render address
$(frm.fields_dict['address_html'].wrapper)
.html(frappe.render_template("address_list",
cur_frm.doc.__onload))
.find(".btn-address").on("click", function() {
frappe.new_doc("Address");
});

// render contact
if(frm.fields_dict['contact_html']) {
$(frm.fields_dict['contact_html'].wrapper)
.html(frappe.render_template("contact_list",
cur_frm.doc.__onload))
.find(".btn-contact").on("click", function() {
frappe.new_doc("Contact");
}
);
console.log("my file trigger")
}
}
})

Result:
Use this code to change rendering of Address and Contact: