chore: fix WRONG FILE PATH - write JS to correct Frappe-resolved path (two-level-deep) with full customer clear + Description visible

This commit is contained in:
root 2026-07-16 17:46:51 +00:00
parent bab40d090d
commit 276bc18c32
2 changed files with 33 additions and 25 deletions

View file

@ -1,6 +1,6 @@
# Service Factory — ERPNext Custom App Project
> **Current Version: V0.1.0024** — Each completed prompt/step increments the patch number by 1 (V0.1.0000 → V0.1.0001 → V0.1.0002…). The agent automatically commits and pushes after every step.
> **Current Version: V0.1.0025** — Each completed prompt/step increments the patch number by 1 (V0.1.0000 → V0.1.0001 → V0.1.0002…). The agent automatically commits and pushes after every step.
## Project Overview

View file

@ -1,5 +1,5 @@
// Copyright (c) 2026, cclohmar and contributors
// For license information, please see license.txt
// For license information, see please license.txt
frappe.ui.form.on("Engagement Card", {
onload: function (frm) {
@ -89,7 +89,6 @@ frappe.ui.form.on("Engagement Card", {
},
// Re-filter opportunities when customer changes
customer: function (frm) {
// Clear the "auto-selected" flag so we don't block legitimate user selections
frm._cust_user_selected = true;
frm.set_query("opportunity", function () {
let filters = {};
@ -102,36 +101,45 @@ frappe.ui.form.on("Engagement Card", {
});
function clear_customer_field(frm) {
if (!frm.is_new()) return;
// Prevent Frappe from caching this field's value across sessions
if (frappe.boot && frappe.boot.user && frappe.boot.user.last_selected_values) {
if (frappe.boot?.user?.last_selected_values) {
delete frappe.boot.user.last_selected_values.Customer;
}
// Model-level clear
frm.set_value("customer", null);
// Clear at the model level (direct, bypasses event triggers)
frm.doc.customer = null;
// Force-clear at the DOM and Awesomplete level after render is complete
setTimeout(() => {
// Also clear through Frappe's model API
frappe.model.set_value(frm.doctype, frm.docname, "customer", null);
// Force-clear at the DOM and Awesomplete level repeatedly
// to catch any delayed re-population during form init
let attempts = 0;
const max_attempts = 10;
const timer = setInterval(() => {
attempts++;
let field = frm.get_field("customer");
if (!field) return;
// Clear the input DOM value
if (field) {
if (field.$input) {
field.$input.val("");
}
// Reset Awesomplete's internal selection state
if (field.awesomplete) {
field.awesomplete.index = -1;
field.awesomplete.selected = false;
// Disable autoFirst to prevent highlight-latching on first item
field.awesomplete.autoFirst = false;
}
// Reset field value tracking so blur handler sees no change
field.last_value = null;
field.value = null;
}, 200);
}
if (frm.doc) {
frm.doc.customer = null;
}
if (attempts >= max_attempts || !frm.is_new() || frm.doc.__islocal === 0) {
clearInterval(timer);
}
}, 150);
}
function load_select_options(frm) {