Open KanchanChauhan opened 1 month ago
BLOCKER:
For timesheet approval, the API in frappe_pms loops over the timesheet entries and updates the approval status like this:
# file: api/timesheet.py
length = len(timesheets)
for index, timesheet in enumerate(timesheets):
doc = frappe.get_doc("Timesheet", timesheet.name)
doc.custom_approval_status = "Approval Pending"
doc.save()
So, the slack notification is being triggered multiple times for each timesheet update:
def on_update(doc, method):
"""
Send a slack message to the timesheet approver when a new timesheet
is submitted for approval.
"""
if doc.custom_weekly_approval_status == "Approval Pending":
frappe.enqueue(
send_timesheet_approval_notification_bg,
queue="short",
doc=doc,
)
Getting multiples:
@ananyo141 We will have to implement this particular Notification in rtCamp since it is very specific to rtCamp as Approval Status is our custom field and only we follow weekly submissions and approvals.
Notify the Project Manager when an employee submits a timesheet for approval and
Send notification on Timesheet submitted for Approval
is checked on Slack Settings.Notification message: "{{employee}} has submitted a timesheet for approval. {{link to employee timesheet on app}}"