chore: replace team members nested grid with Department-based employee lookup
This commit is contained in:
parent
a9eda9c460
commit
9447f16d11
5 changed files with 55 additions and 62 deletions
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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" },
|
||||||
|
|
|
||||||
|
|
@ -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" },
|
||||||
|
|
|
||||||
|
|
@ -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 []
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,46 +1,40 @@
|
||||||
{
|
{
|
||||||
"actions": [],
|
"actions": [],
|
||||||
"allow_rename": 0,
|
"allow_rename": 0,
|
||||||
"autoname": "hash",
|
"autoname": "hash",
|
||||||
"creation": "2026-07-16 12:00:00.000000",
|
"creation": "2026-07-16 12:00:00.000000",
|
||||||
"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",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Team Name",
|
"label": "Team Name",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "department",
|
"fieldname": "department",
|
||||||
"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",
|
"istable": 1,
|
||||||
"label": "Team Members",
|
"links": [],
|
||||||
"options": "SF Settings Team Member",
|
"modified": "2026-07-16 12:00:00.000000",
|
||||||
"reqd": 0
|
"modified_by": "Administrator",
|
||||||
}
|
"module": "Service Factory",
|
||||||
],
|
"name": "SF Settings Team",
|
||||||
"istable": 1,
|
"naming_rule": "Random",
|
||||||
"links": [],
|
"owner": "Administrator",
|
||||||
"modified": "2026-07-16 12:00:00.000000",
|
"permissions": [],
|
||||||
"modified_by": "Administrator",
|
"sort_field": "modified",
|
||||||
"module": "Service Factory",
|
"sort_order": "DESC",
|
||||||
"name": "SF Settings Team",
|
"states": [],
|
||||||
"naming_rule": "Random",
|
"track_changes": 0
|
||||||
"owner": "Administrator",
|
}
|
||||||
"permissions": [],
|
|
||||||
"sort_field": "modified",
|
|
||||||
"sort_order": "DESC",
|
|
||||||
"states": [],
|
|
||||||
"track_changes": 0
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue