Technical

ERPNext Workflows and Approvals: States, Roles and Notifications

How to build approval workflows in ERPNext: plan states and transitions, set role-based approvals for purchase orders and expense claims, and send the right notifications at each step.

Kalvyai Engineering · · 8 min read

ERPNext Workflows and Approvals: States, Roles and Notifications (cover)
On this page

Most approval problems in ERPNext look the same. Purchase orders get submitted without anyone checking them. Expense claims sit in someone's inbox for weeks. Nobody can say who approved what. ERPNext has a built-in Workflow feature that fixes most of this without custom code. This post covers how workflows are built, how to set up role-based approvals for purchase orders and expense claims, and how to notify the right people at each step.

How ERPNext workflows work

A workflow in ERPNext (from the Frappe framework underneath it) is attached to one document type, such as Purchase Order or Expense Claim. Only one workflow can be active per document type. Once it is active, the normal Submit button is replaced by an Actions menu that shows only the moves the current user is allowed to make.

The building blocks

A workflow is made of a few records:

  • Workflow State: a named stage, such as "Draft", "Pending Manager Approval" or "Approved". States are shared records, so you can reuse them across workflows.
  • Workflow Action Master: the name of a button, such as "Submit for Approval", "Approve" or "Reject".
  • Workflow: the record that ties it together. It has a States table and a Transitions table.

In the States table, each row sets:

  • The state name
  • The Doc Status the document should have in that state (0 = Draft, 1 = Submitted, 2 = Cancelled)
  • Only Allow Edit For: the role that can edit the document while it is in this state
  • Optional Update Field and Update Value, which set a field on the document when it enters the state

In the Transitions table, each row sets:

  • State: where the document is now
  • Action: the button label
  • Next State: where it goes
  • Allowed: the role that can click the button
  • Allow Self Approval: whether the document owner can perform this action on their own document
  • Condition: an optional Python expression that must be true for the transition to show

When you save the workflow, Frappe adds a workflow_state field to the document type (the field name is configurable on the Workflow record) to track the current state.

Doc status rules

The Doc Status column is where most first attempts go wrong. Frappe documents follow a strict path:

  • 0 to 0 (draft to draft) is allowed
  • 0 to 1 (draft to submitted) is allowed
  • 1 to 2 (submitted to cancelled) is allowed
  • 1 back to 0 is not allowed

So any state where people are still reviewing must have Doc Status 0. Only the final "Approved" state should be 1. A "Rejected" state that is reached before submission should also be 0. If you reject a document after it is submitted, the state needs Doc Status 2, which cancels it.

Plan the workflow before you build it

Write the workflow down first. A simple table is enough, and it is what you will review with the business owner before touching the system.

Plain text
State                       Doc Status   Edit allowed for
Draft                       0            Purchase User
Pending Manager Approval    0            Purchase Manager
Pending Director Approval   0            Purchase Director
Approved                    1            Purchase Manager
Rejected                    0            Purchase User
Cancelled                   2            Purchase Manager

From                        Action                Next state                  Role               Condition
Draft                       Submit for Approval   Pending Manager Approval    Purchase User
Pending Manager Approval    Approve               Approved                    Purchase Manager   doc.grand_total <= 50000
Pending Manager Approval    Approve               Pending Director Approval   Purchase Manager   doc.grand_total > 50000
Pending Manager Approval    Reject                Rejected                    Purchase Manager
Pending Director Approval   Approve               Approved                    Purchase Director
Pending Director Approval   Reject                Rejected                    Purchase Director
Rejected                    Revise                Draft                       Purchase User
Approved                    Cancel                Cancelled                   Purchase Manager

The 50,000 limit is an example. Use your own approval matrix. "Purchase Director" is a custom role in this example; "Purchase User" and "Purchase Manager" are standard ERPNext roles.

Questions to answer at this stage:

  • Who can raise the document, and who approves at each level?
  • What amount or condition moves a document to the next level?
  • Can someone approve their own document?
  • What happens after rejection: edit and resubmit, or start over?
  • Who needs to know when each state changes?

Purchase order approval, step by step

1. Create the roles

  1. Open the Role list (type "Role List" in the search bar).
  2. Create any roles you need that do not exist yet, such as "Purchase Director".
  3. Give the role permissions on Purchase Order through Role Permissions Manager. Approvers need at least Read, Write and Submit. The role that cancels needs Cancel.
  4. Assign the roles to the right users on their User record.

A user must have the role in the Allowed column of a transition and the matching document permission. If either is missing, the action button will not appear.

2. Create the states and actions

You can create Workflow State and Workflow Action Master records first, or type new names directly into the workflow tables and create them from there. Use clear names. They appear on list views, reports and emails.

3. Build the workflow

  1. Open the Workflow list (type "Workflow List" in the search bar) and create a new one.
  2. Set Document Type to Purchase Order.
  3. Fill the States table from your plan.
  4. Fill the Transitions table from your plan.
  5. Add the conditions on the amount-based transitions.
  6. Untick Allow Self Approval on approval transitions if a buyer who also holds the Purchase Manager role should not approve their own orders.
  7. Tick Is Active and save.

Newer Frappe versions also include a visual Workflow Builder for editing states and transitions as a diagram.

4. Write conditions

Conditions are Python expressions evaluated against the document as doc. Keep them short:

Python
doc.grand_total > 50000
Python
doc.grand_total > 50000 and doc.company == "Acme India Pvt Ltd"

Only a limited set of functions is available inside conditions (for example frappe.db.get_value and frappe.session). The help text under the Condition field lists what your version allows. If the logic needs more than that, move it into a custom field that is set by a server script or app code, and test that field in the condition.

Make sure conditions on the same "from" state cover every case. If one transition is > 50000 and the other is < 50000, an order of exactly 50,000 has no Approve button.

5. Test with real users

Log in as each role, or use separate browser profiles, and walk a document through every path: low value, high value, rejected, revised and cancelled. Check that:

  • Each user sees only the actions meant for them
  • The final approval submits the document
  • A rejected document can be edited by the requester and sent back
  • The document timeline shows each state change and who made it

That timeline is your audit trail. Every workflow action is recorded against the document.

Expense claim approval

In current versions, Expense Claim lives in the Frappe HR (HRMS) app, not core ERPNext. It already has an Expense Approver field and an Approval Status field. A claim cannot be submitted while Approval Status is still "Draft"; it must be "Approved" or "Rejected".

That gives you a clean pattern: let the workflow set Approval Status using the Update Field and Update Value columns.

Plain text
State                Doc Status   Edit allowed for   Update Field      Update Value
Draft                0            Employee
Pending Approval     0            Expense Approver
Approved             1            Expense Approver   approval_status   Approved
Rejected             1            Expense Approver   approval_status   Rejected

Here "Rejected" uses Doc Status 1, because a rejected claim is a final record that is submitted with that status. If you prefer the employee to fix and resend a rejected claim, add a "Sent Back" state with Doc Status 0 and a transition back to Draft instead.

Approving only your own team's claims

The "Expense Approver" role alone lets any approver act on any claim they can see. To restrict approval to the person named on the claim, add a condition on the Approve and Reject transitions:

Python
doc.expense_approver == frappe.session.user

The approver is usually filled from the employee's department or reporting setup. Also review whether HR Settings require an expense approver on every claim.

For multi-level claims, such as a finance check above a limit, add a second pending state with a condition on doc.total_sanctioned_amount or doc.grand_total, the same way as the purchase order example.

Notifications

An approval step nobody knows about is a delay. ERPNext gives you two ways to notify people.

Workflow emails and Workflow Actions

On the Workflow record, Send Email Alert sends an email to users who can act on the document when it reaches a state. Frappe also creates Workflow Action records for pending approvals, so approvers can see their queue in one list. In the States table you can choose a Next Action Email Template per state to control the wording.

This is the quickest setup, but it targets everyone with the allowed role. If ten people have Purchase Manager, all ten get the email.

The Notification doctype

For finer control, use Notification (type "Notification List" in the search bar). A notification can send by Email or System Notification, among other channels, and can target a field on the document, a role, or fixed addresses.

To alert directors when a purchase order needs them:

  1. Create a new Notification.
  2. Set Document Type to Purchase Order.
  3. Set Send Alert On to "Value Change" and Value Changed to the workflow state field.
  4. Set Condition to doc.workflow_state == "Pending Director Approval".
  5. Under Recipients, add the role "Purchase Director".
  6. Write the subject and message.

The message supports Jinja:

HTML
<p>Purchase Order {{ doc.name }} from {{ doc.supplier }} needs your approval.</p>
<p>Total: {{ doc.get_formatted("grand_total") }}</p>
<p>Raised by: {{ doc.owner }}</p>

For expense claims, use the document field expense_approver as the recipient, so only the named approver is emailed. Add a second notification on the "Approved" and "Rejected" states that goes to the employee, so they know the outcome without asking.

Avoid duplicates: if you use Notification for approvers, consider turning off Send Email Alert on the workflow, or people will get two emails for the same step.

Moving workflows between sites

Build and test on a staging site, then move the setup to production. If you manage changes in a custom app, export the records as fixtures in hooks.py:

Python
fixtures = [
    "Workflow",
    "Workflow State",
    "Workflow Action Master",
    {"dt": "Notification", "filters": [["name", "in", ["PO Director Approval"]]]},
    {"dt": "Role", "filters": [["name", "in", ["Purchase Director"]]]},
]

Then export from the staging site:

Bash
bench --site staging.example.com export-fixtures

The fixtures are imported when the app is migrated on the target site. Filter fixtures tightly so you do not overwrite records that belong to someone else.

Common mistakes

  • Activating a workflow on a live document type without a plan for existing drafts. Drafts created before the workflow may have an empty state. Decide whether to set them to a starting state in bulk.
  • Approval states with Doc Status 1 in the middle of the flow. Once submitted, the document cannot return to draft, so later rejection becomes a cancellation.
  • Gaps in conditions. Check boundary values like exactly 50,000.
  • Missing permissions. The role is in the Allowed column but has no Submit permission on the document type.
  • Leaving Allow Self Approval on where segregation of duties matters.
  • Notifying a whole role when only one person should act.
  • Not testing as each role. Testing as Administrator hides almost every permission problem.

How Kalvyai can help

We design and build ERPNext approval flows as part of our ERPNext work: mapping your approval matrix, setting up roles, workflows and notifications, packaging them as fixtures, and testing every path before go-live. We also add AI agents that work inside ERPNext under the same rules, with human approvals, budgets and an audit trail. Our ready-made apps are at store.kalvyai.com.

If your approvals live in email threads today, get in touch and we will help you move them into ERPNext.

Share this article

  • ERPNext
  • Frappe
  • Workflows
  • Approvals
  • Purchase Orders
  • Expense Claims
  • Notifications

Kalvyai Engineering · Engineering team

The engineers who build, connect and fix business systems at Kalvyai: Odoo, ERPNext, Shopify and AI agents that work inside them with approvals, budgets and an audit trail.

Comments

No comments yet. Questions and corrections are welcome.

Rate this post or leave a comment

Your rating (optional)
Not rated

Comments appear after an editor approves them. See our privacy notice.

Read next

ERPNext Bank Reconciliation: Import, Match and Clear Transactions (cover)Technical
Kalvyai EngineeringERPNext

ERPNext Bank Reconciliation: Import, Match and Clear Transactions

A practical guide to bank reconciliation in ERPNext: setting up bank accounts, importing statements, matching Payment Entries and Journal Entries in the Bank Reconciliation Tool, and dealing with transactions that don't match.

8 min read

Newsletter

Get new guides in your inbox.

Practical notes on Odoo, ERPNext, Shopify and AI agents, written by the engineers who build them. No spam, and you can ask to stop at any time.

Prefer a feed? Subscribe by RSS. We use your email only to send new articles. See our privacy policy.