Fixed customer quick entry rollback error.
This commit is contained in:
@@ -3,14 +3,39 @@ frappe.provide("ns_app.customer");
|
|||||||
// Preserve original quick entry
|
// Preserve original quick entry
|
||||||
const _make_quick_entry = frappe.ui.form.make_quick_entry;
|
const _make_quick_entry = frappe.ui.form.make_quick_entry;
|
||||||
|
|
||||||
|
console.log("NS APP CUSTOMER JS LOADED");
|
||||||
|
|
||||||
// Override
|
// Override
|
||||||
frappe.ui.form.make_quick_entry = function (doctype, after_insert) {
|
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");
|
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({
|
ns_app.customer.open_quick_entry({
|
||||||
callback: after_insert,
|
callback: after_insert,
|
||||||
route_options: frappe.route_options || {}
|
customer_name: customer_name
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,7 +58,7 @@ ns_app.customer.open_quick_entry = function (opts = {}) {
|
|||||||
label: "Customer Name",
|
label: "Customer Name",
|
||||||
fieldtype: "Data",
|
fieldtype: "Data",
|
||||||
reqd: 1,
|
reqd: 1,
|
||||||
default: opts.route_options?.customer_name || ""
|
default: opts.customer_name || ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "customer_type",
|
fieldname: "customer_type",
|
||||||
@@ -131,8 +156,8 @@ ns_app.customer.open_quick_entry = function (opts = {}) {
|
|||||||
indicator: "green"
|
indicator: "green"
|
||||||
});
|
});
|
||||||
|
|
||||||
if (opts.callback && r.message) {
|
if (opts.callback) {
|
||||||
opts.callback(r.message.name || r.message);
|
opts.callback(r.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
always() {
|
always() {
|
||||||
|
|||||||
Reference in New Issue
Block a user