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

View file

@ -173,7 +173,7 @@ function load_select_options(frm) {
frm.refresh_field("task"); 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({ frappe.call({
method: "service_factory.service_factory.doctype.engagement_card.engagement_card.get_options_for", method: "service_factory.service_factory.doctype.engagement_card.engagement_card.get_options_for",
args: { fieldname: "team" }, args: { fieldname: "team" },

View file

@ -173,7 +173,7 @@ function load_select_options(frm) {
frm.refresh_field("task"); 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({ frappe.call({
method: "service_factory.service_factory.doctype.engagement_card.engagement_card.get_options_for", method: "service_factory.service_factory.doctype.engagement_card.engagement_card.get_options_for",
args: { fieldname: "team" }, args: { fieldname: "team" },

View file

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

View file

@ -1,4 +1,4 @@
{ {
"actions": [], "actions": [],
"allow_rename": 0, "allow_rename": 0,
"autoname": "hash", "autoname": "hash",
@ -6,7 +6,7 @@
"doctype": "DocType", "doctype": "DocType",
"editable_grid": 1, "editable_grid": 1,
"engine": "InnoDB", "engine": "InnoDB",
"field_order": ["team_name", "department", "members"], "field_order": ["team_name", "department"],
"fields": [ "fields": [
{ {
"fieldname": "team_name", "fieldname": "team_name",
@ -20,14 +20,8 @@
"fieldtype": "Link", "fieldtype": "Link",
"in_list_view": 1, "in_list_view": 1,
"label": "Department", "label": "Department",
"options": "Department" "options": "Department",
}, "reqd": 1
{
"fieldname": "members",
"fieldtype": "Table",
"label": "Team Members",
"options": "SF Settings Team Member",
"reqd": 0
} }
], ],
"istable": 1, "istable": 1,
@ -43,4 +37,4 @@
"sort_order": "DESC", "sort_order": "DESC",
"states": [], "states": [],
"track_changes": 0 "track_changes": 0
} }