chore: replace team members nested grid with Department-based employee lookup

This commit is contained in:
root 2026-07-17 14:56:38 +00:00
parent a9eda9c460
commit 9447f16d11
5 changed files with 55 additions and 62 deletions

View file

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

@ -173,7 +173,7 @@ function load_select_options(frm) {
frm.refresh_field("task");
}
// Load teams with members via the filtered API
// Load teams that have a department linked via the filtered API
frappe.call({
method: "service_factory.service_factory.doctype.engagement_card.engagement_card.get_options_for",
args: { fieldname: "team" },

View file

@ -173,7 +173,7 @@ function load_select_options(frm) {
frm.refresh_field("task");
}
// Load teams with members via the filtered API
// Load teams that have a department linked via the filtered API
frappe.call({
method: "service_factory.service_factory.doctype.engagement_card.engagement_card.get_options_for",
args: { fieldname: "team" },

View file

@ -30,7 +30,7 @@ class EngagementCard(Document):
self.title = f"EC-{self.name or 'new'}"
def sync_team_members(self):
"""Populate assignments from selected Team in Settings."""
"""Populate assignments from active employees in team's linked Department."""
if not self.team:
return
@ -44,17 +44,19 @@ class EngagementCard(Document):
team_row = t
break
if not team_row:
if not team_row or not team_row.department:
return
self.set("assignments", [])
members = team_row.get("members", [])
if not members:
return
for member in members:
employees = frappe.get_all(
"Employee",
filters={"department": team_row.department, "status": "Active"},
fields=["name", "employee_name"],
)
for emp in employees:
row = self.append("assignments", {})
row.employee = member.employee
row.role = member.role
row.employee = emp.name
row.employee_name = emp.employee_name
row.allocated_hours = 0
row.logged_hours = 0
@ -93,11 +95,8 @@ def get_options_for(fieldname):
if fieldname == "task":
return [r.task_type_name for r in settings.task_types]
elif fieldname == "team":
# Only return teams that have at least one member configured
return [
r.team_name for r in settings.teams
if len(r.get("members", [])) > 0
]
# Only return teams that have a department linked
return [r.team_name for r in settings.teams if r.department]
return []

View file

@ -1,46 +1,40 @@
{
"actions": [],
"allow_rename": 0,
"autoname": "hash",
"creation": "2026-07-16 12:00:00.000000",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": ["team_name", "department", "members"],
"fields": [
{
"fieldname": "team_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Team Name",
"reqd": 1
},
{
"fieldname": "department",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Department",
"options": "Department"
},
{
"fieldname": "members",
"fieldtype": "Table",
"label": "Team Members",
"options": "SF Settings Team Member",
"reqd": 0
}
],
"istable": 1,
"links": [],
"modified": "2026-07-16 12:00:00.000000",
"modified_by": "Administrator",
"module": "Service Factory",
"name": "SF Settings Team",
"naming_rule": "Random",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 0
}
{
"actions": [],
"allow_rename": 0,
"autoname": "hash",
"creation": "2026-07-16 12:00:00.000000",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": ["team_name", "department"],
"fields": [
{
"fieldname": "team_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Team Name",
"reqd": 1
},
{
"fieldname": "department",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Department",
"options": "Department",
"reqd": 1
}
],
"istable": 1,
"links": [],
"modified": "2026-07-16 12:00:00.000000",
"modified_by": "Administrator",
"module": "Service Factory",
"name": "SF Settings Team",
"naming_rule": "Random",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 0
}