chore: hide creation-only fields on new form, filter opp by customer
This commit is contained in:
parent
e84b04ddd8
commit
cc76feff29
3 changed files with 81 additions and 41 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# Service Factory — ERPNext Custom App Project
|
# 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
|
## Project Overview
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,25 @@
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Engagement Card", {
|
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) {
|
refresh: function (frm) {
|
||||||
load_select_options(frm);
|
load_select_options(frm);
|
||||||
|
toggle_creation_fields(frm);
|
||||||
|
|
||||||
// Quick status actions
|
// 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.add_custom_button(__("Move to Delivery"), function () {
|
||||||
frm.set_value("status", "Delivery");
|
frm.set_value("status", "Delivery");
|
||||||
frm.save();
|
frm.save();
|
||||||
|
|
@ -23,43 +38,55 @@ frappe.ui.form.on("Engagement Card", {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log Activity quick action
|
// Log Activity quick action (only for saved cards)
|
||||||
frm.add_custom_button(__("Log Activity"), function () {
|
if (!frm.is_new()) {
|
||||||
let d = new frappe.ui.Dialog({
|
frm.add_custom_button(__("Log Activity"), function () {
|
||||||
title: __("Log Activity"),
|
let d = new frappe.ui.Dialog({
|
||||||
fields: [
|
title: __("Log Activity"),
|
||||||
{
|
fields: [
|
||||||
label: "Activity Type",
|
{
|
||||||
fieldname: "activity_type",
|
label: "Activity Type",
|
||||||
fieldtype: "Select",
|
fieldname: "activity_type",
|
||||||
options: ["Comment", "Milestone", "Note"],
|
fieldtype: "Select",
|
||||||
reqd: 1,
|
options: ["Comment", "Milestone", "Note"],
|
||||||
|
reqd: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Content",
|
||||||
|
fieldname: "content",
|
||||||
|
fieldtype: "Text Editor",
|
||||||
|
reqd: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Mark as Milestone",
|
||||||
|
fieldname: "is_milestone",
|
||||||
|
fieldtype: "Check",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
primary_action: function () {
|
||||||
|
let data = d.get_values();
|
||||||
|
let child = frm.add_child("activity_log");
|
||||||
|
child.posted_by = frappe.session.user;
|
||||||
|
child.timestamp = frappe.datetime.now_datetime();
|
||||||
|
child.activity_type = data.activity_type;
|
||||||
|
child.content = data.content;
|
||||||
|
child.is_milestone = data.is_milestone;
|
||||||
|
frm.refresh_field("activity_log");
|
||||||
|
d.hide();
|
||||||
},
|
},
|
||||||
{
|
});
|
||||||
label: "Content",
|
d.show();
|
||||||
fieldname: "content",
|
|
||||||
fieldtype: "Text Editor",
|
|
||||||
reqd: 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Mark as Milestone",
|
|
||||||
fieldname: "is_milestone",
|
|
||||||
fieldtype: "Check",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
primary_action: function () {
|
|
||||||
let data = d.get_values();
|
|
||||||
let child = frm.add_child("activity_log");
|
|
||||||
child.posted_by = frappe.session.user;
|
|
||||||
child.timestamp = frappe.datetime.now_datetime();
|
|
||||||
child.activity_type = data.activity_type;
|
|
||||||
child.content = data.content;
|
|
||||||
child.is_milestone = data.is_milestone;
|
|
||||||
frm.refresh_field("activity_log");
|
|
||||||
d.hide();
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
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;
|
if (!r.message) return;
|
||||||
let doc = r.message;
|
let doc = r.message;
|
||||||
|
|
||||||
// Set task options
|
|
||||||
if (doc.task_types && doc.task_types.length) {
|
if (doc.task_types && doc.task_types.length) {
|
||||||
let opts = "\n" + doc.task_types.map((t) => t.task_type_name).join("\n");
|
let opts = "\n" + doc.task_types.map((t) => t.task_type_name).join("\n");
|
||||||
frm.set_df_property("task", "options", opts);
|
frm.set_df_property("task", "options", opts);
|
||||||
frm.refresh_field("task");
|
frm.refresh_field("task");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set team options
|
|
||||||
if (doc.teams && doc.teams.length) {
|
if (doc.teams && doc.teams.length) {
|
||||||
let opts = "\n" + doc.teams.map((t) => t.team_name).join("\n");
|
let opts = "\n" + doc.teams.map((t) => t.team_name).join("\n");
|
||||||
frm.set_df_property("team", "options", opts);
|
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
|
// Time log rollup
|
||||||
frappe.ui.form.on("Engagement Card Time Log", {
|
frappe.ui.form.on("Engagement Card Time Log", {
|
||||||
hours: function (frm) {
|
hours: function (frm) {
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "Task",
|
"label": "Task",
|
||||||
"options": "",
|
"options": "\nDemo\nPOC\nDeployment\nRFP / RFI\nOther",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -112,7 +112,7 @@
|
||||||
"fieldname": "team",
|
"fieldname": "team",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Team",
|
"label": "Team",
|
||||||
"options": ""
|
"options": "\n--- Configure teams in Service Factory Settings ---"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "section_break_desc",
|
"fieldname": "section_break_desc",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue