Skip to content

Commit

Permalink
fix(patch): consider only active agents
Browse files Browse the repository at this point in the history
  • Loading branch information
RitvikSardana committed Nov 11, 2024
1 parent 3de5672 commit 6de7fdb
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions helpdesk/patches/update_hd_team_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ def execute():
for team in teams:
existing_agents = frappe.get_all(
"HD Team Item", filters={"team": team}, pluck="parent"
)
) # agents in HD Agent doctype
team_users = frappe.get_all(
"HD Team Member", filters={"parent": team}, pluck="user"
)
) # agents in HD Team doctype

for agent in existing_agents:
if agent not in team_users:
team_doc = (
frappe.get_doc("HD Team", team)
.append("users", {"user": agent})
.save()
)
print("Agent Added")
is_agent_active = frappe.get_value("HD Agent", agent, "is_active")
if not is_agent_active:
continue

if is_agent_active:
if agent not in team_users:
team_doc = (
frappe.get_doc("HD Team", team)
.append("users", {"user": agent})
.save()
)
print("Agent Added")

0 comments on commit 6de7fdb

Please sign in to comment.