chore: hide creation-only fields on new form, filter opp by customer

This commit is contained in:
root 2026-07-16 16:58:35 +00:00
parent e84b04ddd8
commit cc76feff29
3 changed files with 81 additions and 41 deletions

View file

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

@ -2,10 +2,25 @@
// For license information, please see license.txt
frappe.ui.form.on("Engagement Card", {
onload: function (frm) {
load_select_options(frm);
toggle_creation_fields(frm);
// Filter opportunities by customer
frm.set_query("opportunity", function () {
let filters = {};
if (frm.doc.customer) {
filters.customer = frm.doc.customer;
}
return { filters: filters };
});
},
refresh: function (frm) {
load_select_options(frm);
toggle_creation_fields(frm);
// Quick status actions
if (frm.doc.status === "Discovery") {
if (frm.doc.status === "Discovery" && !frm.is_new()) {
frm.add_custom_button(__("Move to Delivery"), function () {
frm.set_value("status", "Delivery");
frm.save();
@ -23,7 +38,8 @@ frappe.ui.form.on("Engagement Card", {
});
}
// Log Activity quick action
// Log Activity quick action (only for saved cards)
if (!frm.is_new()) {
frm.add_custom_button(__("Log Activity"), function () {
let d = new frappe.ui.Dialog({
title: __("Log Activity"),
@ -61,6 +77,17 @@ frappe.ui.form.on("Engagement Card", {
});
d.show();
});
}
},
// Re-filter opportunities when customer changes
customer: function (frm) {
frm.set_query("opportunity", function () {
let filters = {};
if (frm.doc.customer) {
filters.customer = frm.doc.customer;
}
return { filters: filters };
});
},
});
@ -75,14 +102,12 @@ function load_select_options(frm) {
if (!r.message) return;
let doc = r.message;
// Set task options
if (doc.task_types && doc.task_types.length) {
let opts = "\n" + doc.task_types.map((t) => t.task_type_name).join("\n");
frm.set_df_property("task", "options", opts);
frm.refresh_field("task");
}
// Set team options
if (doc.teams && doc.teams.length) {
let opts = "\n" + doc.teams.map((t) => t.team_name).join("\n");
frm.set_df_property("team", "options", opts);
@ -92,6 +117,21 @@ function load_select_options(frm) {
});
}
function toggle_creation_fields(frm) {
let hide = frm.is_new();
let sections = [
"section_break_desc",
"section_break_budget",
"section_break_assignments",
"section_break_activity",
"section_break_time",
"section_break_subtasks",
];
sections.forEach(function (section) {
frm.toggle_display(section, !hide);
});
}
// Time log rollup
frappe.ui.form.on("Engagement Card Time Log", {
hours: function (frm) {

View file

@ -61,7 +61,7 @@
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Task",
"options": "",
"options": "\nDemo\nPOC\nDeployment\nRFP / RFI\nOther",
"reqd": 1
},
{
@ -112,7 +112,7 @@
"fieldname": "team",
"fieldtype": "Select",
"label": "Team",
"options": ""
"options": "\n--- Configure teams in Service Factory Settings ---"
},
{
"fieldname": "section_break_desc",