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 # 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 ## Project Overview

View file

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