chore: fix Select dropdown options loading from Settings

This commit is contained in:
root 2026-07-16 14:43:30 +00:00
parent 7243188e97
commit e84b04ddd8
2 changed files with 19 additions and 32 deletions

View file

@ -1,6 +1,6 @@
# Service Factory — ERPNext Custom App Project # Service Factory — ERPNext Custom App Project
> **Current Version: V0.1.0017** — 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.0018** — 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

@ -3,9 +3,7 @@
frappe.ui.form.on("Engagement Card", { frappe.ui.form.on("Engagement Card", {
refresh: function (frm) { refresh: function (frm) {
// Load dynamic options from Settings load_select_options(frm);
load_options(frm);
// Quick status actions // Quick status actions
if (frm.doc.status === "Discovery") { if (frm.doc.status === "Discovery") {
frm.add_custom_button(__("Move to Delivery"), function () { frm.add_custom_button(__("Move to Delivery"), function () {
@ -66,41 +64,30 @@ frappe.ui.form.on("Engagement Card", {
}, },
}); });
function load_options(frm) { function load_select_options(frm) {
// Fetch task options from Settings
frappe.call({ frappe.call({
method: "frappe.client.get_single_value", method: "frappe.client.get",
args: { args: {
doctype: "Service Factory Settings", doctype: "Service Factory Settings",
name: "Service Factory Settings",
}, },
callback: function (r) { callback: function (r) {
if (!r.message) return; if (!r.message) return;
let doc = r.message;
// Get task types - need full doc for table fields // Set task options
frappe.call({ if (doc.task_types && doc.task_types.length) {
method: "frappe.client.get", let opts = "\n" + doc.task_types.map((t) => t.task_type_name).join("\n");
args: { frm.set_df_property("task", "options", opts);
doctype: "Service Factory Settings", frm.refresh_field("task");
name: "Service Factory Settings", }
},
callback: function (resp) { // Set team options
let doc = resp.message; if (doc.teams && doc.teams.length) {
if (doc.task_types) { let opts = "\n" + doc.teams.map((t) => t.team_name).join("\n");
let task_options = doc.task_types frm.set_df_property("team", "options", opts);
.map((t) => t.task_type_name) frm.refresh_field("team");
.join("\n"); }
frm.set_df_property("task", "options", "\n" + task_options);
frm.refresh_field("task");
}
if (doc.teams) {
let team_options = doc.teams
.map((t) => t.team_name)
.join("\n");
frm.set_df_property("team", "options", "\n" + team_options);
frm.refresh_field("team");
}
},
});
}, },
}); });
} }