Multi-approver "workflow" for Purchase Order and Purchase Invoice

Hi,
my company was in need for a custom, multi-approver workflow for purchases.

I tried using ERPnext workflows, but, while nice, they are not suitable for the task (the scripting capabilities are too limited). I thus implemented the workflow on my own as a customization to the Purchase Order and Purchase Invoice Doctypes. The change is generic enough that it could be back-ported to any other Doctype with a little effort.

We use the code in production, so I feel very confident about it, but I haven’t had the chance to run unit tests because I keep getting error messages regarding other modules, completely unrelated, and right now I don’t have the time to find out what’s going on.

I am kindly looking for developers willing to cross-check my code and help me with the automated testing.

You can find my code at https://github.com/theonlynexus/erpnext/tree/version-12-with-approval.
In particular refer to commit 1d9a366, as the next commit (commit a86cfd3) was pushed to the branch by mistake.

Thanks, and I hope you find my submission useful.

— EDIT —

I thought that giving a little bit more context might help.

The workflow is as follows:

  • Each of Purchase Order and Purchase Invoice has a section dedicated to approval
  • There one can specify:
    – if the order has to be approved
    – the approvers
    – the minimum number of approvals required (defaults to the number of approvers)

If the documents require approval, then the status is set to “To Approve” and the approval status to “Pending”. Once enough approvals have been reached the normal workflow resumes (e.g. status becomes “Unpaid” for Purchase Invoices) and the approval status is set to “Approved”. If the approval quota cannot be reached, then both the document status and the approval status are set to “Rejected”.

2 Likes