From f03fa451d0f99e4e53158d2c1a653524cb31cf72 Mon Sep 17 00:00:00 2001 From: Ty Reynolds Date: Thu, 7 May 2026 11:44:25 -0400 Subject: [PATCH] Fixed customer quick entry rollback error. --- ns_app/public/js/customer_quick_entry.js | 35 ++++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/ns_app/public/js/customer_quick_entry.js b/ns_app/public/js/customer_quick_entry.js index ef278ee..1f9bf40 100644 --- a/ns_app/public/js/customer_quick_entry.js +++ b/ns_app/public/js/customer_quick_entry.js @@ -3,14 +3,39 @@ frappe.provide("ns_app.customer"); // Preserve original quick entry const _make_quick_entry = frappe.ui.form.make_quick_entry; +console.log("NS APP CUSTOMER JS LOADED"); + // Override frappe.ui.form.make_quick_entry = function (doctype, after_insert) { - if (doctype === "Customer" && frappe.route_options) { + + if (doctype === "Customer") { + console.log("NS App: Intercepted Customer Quick Entry"); + + let customer_name = ""; + + // Pull value from current form route options + if (frappe.route_options?.name) { + customer_name = frappe.route_options.name; + } + + // Fallback: get typed value from active link field + if (!customer_name) { + + const active = document.activeElement; + + if (active && active.value) { + customer_name = active.value; + } + } + + console.log("NS App: Captured customer name:", customer_name); + ns_app.customer.open_quick_entry({ callback: after_insert, - route_options: frappe.route_options || {} + customer_name: customer_name }); + return; } @@ -33,7 +58,7 @@ ns_app.customer.open_quick_entry = function (opts = {}) { label: "Customer Name", fieldtype: "Data", reqd: 1, - default: opts.route_options?.customer_name || "" + default: opts.customer_name || "" }, { fieldname: "customer_type", @@ -131,8 +156,8 @@ ns_app.customer.open_quick_entry = function (opts = {}) { indicator: "green" }); - if (opts.callback && r.message) { - opts.callback(r.message.name || r.message); + if (opts.callback) { + opts.callback(r.message); } }, always() {