Fixed customer quick entry rollback error.

This commit is contained in:
Ty Reynolds
2026-05-07 11:44:25 -04:00
parent 0aef470e00
commit f03fa451d0

View File

@@ -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() {