Skip to content

Commit

Permalink
fix(patch): add patch for updating HD Team
Browse files Browse the repository at this point in the history
  • Loading branch information
RitvikSardana committed Nov 11, 2024
1 parent 8be9bcb commit ef3d3e8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
6 changes: 2 additions & 4 deletions helpdesk/helpdesk/doctype/hd_team/hd_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def on_update(self):
self.update_support_rotations()

def on_trash(self):

# Deletes the assignment rule for this group
try:
frappe.delete_doc("Assignment Rule", self.assignment_rule)
Expand Down Expand Up @@ -78,9 +77,8 @@ def get_assignment_rule(self):
def update_support_rotations(self):
"""
Update the support rotations for the hd_agent
# If agent removed remove from the support rule of the team
# If agent added add to the support rule of the team
# while adding remove from base Support Rotation
# If agent removed, remove from the support rule of the team
# If agent added add to the support rule of the team and also, while adding remove from base Support Rotation
"""
assg_rule_doc = frappe.get_doc("Assignment Rule", self.assignment_rule)
if not assg_rule_doc:
Expand Down
21 changes: 21 additions & 0 deletions helpdesk/patches/update_hd_team_users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import frappe


def execute():
teams = frappe.get_all("HD Team", pluck="name")
for team in teams:
existing_agents = frappe.get_all(
"HD Team Item", filters={"team": team}, pluck="parent"
)
team_users = frappe.get_all(
"HD Team Member", filters={"parent": team}, pluck="user"
)

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")

0 comments on commit ef3d3e8

Please sign in to comment.