Workflow Submits Delivery Note even during Error (frappe.throw)

I have a workflow attached to Delivery Note. It looks like this (honestly there is nothing special about this workflow):

In the DN, if there is insufficient stock for any item you are normally greeted with a message that looks like this:

This is expected.

Problem is, after the error, when you reload the document the workflow status still proceeds to go to the next state and the worse part is the docstatus becomes 1 (i.e. submitted). The error thrown is not from the Delivery Note document, it actually comes from creation of the Stock Ledger Entry.

I have spent a fair bit of time digging through the workflow files,, and really cannot find why it behaves this way.

I am trying to find the place where perhaps a DB rollback is called during such exceptions to see if it doesn’t get called or something in this instance. Does anyone know where this happens? like when a document is submitted and an error is thrown therefore a rollback should be called…

Any help would be great. Thanks.

Am running on V11

Hello @bohlian,

The issue has been recently fixed.

Please update your code. It should fix your issue.

Suraj Shetty

Hi @surajshetty thanks for this! been trying for quite awhile now. Awesome!!