diff --git a/ns_app/public/js/custom.js b/ns_app/public/js/custom.js index 1f96856..366e39d 100644 --- a/ns_app/public/js/custom.js +++ b/ns_app/public/js/custom.js @@ -1 +1,44 @@ -console.log("NS App loaded"); +frappe.ready(() => { + const original_make_quick_entry = frappe.ui.form.make_quick_entry; + + frappe.ui.form.make_quick_entry = function (doctype, after_insert, init_callback) { + if (doctype !== "Customer") { + return original_make_quick_entry.apply(this, arguments); + } + + console.log("NS App: Custom Customer Quick Entry Loaded"); + + return original_make_quick_entry.call( + this, + doctype, + after_insert, + function (doc) { + // Defaults + doc.customer_group = "Commercial"; + doc.territory = "United States"; + + if (init_callback) { + init_callback(doc); + } + } + ); + }; +}); + +frappe.ui.form.on("Customer", { + onload(frm) { + if (!frm.is_quick_entry) return; + + console.log("NS App: Modifying Quick Entry Fields"); + + // Remove unwanted fields + frm.toggle_display("customer_group", false); + + // Make fields required + frm.set_df_property("mobile_no", "reqd", 1); + + // Set default values + frm.set_value("territory", "United States"); + } +}); +