Attendance, Leave and Expense can be approved only by assigned approver

How can I restrict Attendance, Leave and expense request approval only to person assigned as Attendance approver or Expense approver for that employee and not to everyone with submit permission on those doc? How can I ensure that only managers (or manager or manager) of employee with submit permission get to approve/submit the request?

Frappe HR: Restrict Approval to Assigned Approver Only

To resolve the issue where any manager can approve requests, follow these steps to configure a Workflow that checks if the current user is the assigned approver.

1. Basic Information (Header Section)

Fill in the top section of the Workflow page as follows:

  • Workflow Name: Leave Approval Restriction
  • Document Type: Leave Application
  • Is Active: Checked (Enable this to make the workflow live)

2. Document States

Add the following rows to the Document States table:

No. State Doc Status
1 Open 0 (Draft)
2 Approved 1 (Submitted)
3 Rejected 2 (Cancelled)

3. Transition Rules

This is the most important part. It ensures only the assigned approver sees the “Approve” button.

Click Add Row for each action and expand the row (using the arrow on the right) to enter the Condition:

For Approval:

  • State: Open
  • Action: Approve
  • Next State: Approved
  • Allowed: Select the manager’s role (e.g., Leave Approver or HR Manager)
  • Condition: ```python
    doc.leave_approver == session.user


For Rejection:

  • State: Open
  • Action: Reject
  • Next State: Rejected
  • Allowed: Same role as above
  • Condition: ```python
    doc.leave_approver == session.user



4. Finalizing

  • Workflow State Field: Keep it as workflow_state.
  • Save: Click the Save button in the top right corner.
1 Like

(post deleted by author)

Thanks. Could you also suggest how to restrict the email going out for attendance/leave/expense requests only to the manager or the leave/expense approver? Currently, the email goes out to everyone with the role of leave/expense approver.