I created a workflow where the actions are triggered via custom buttons, not the default workflow actions dropdown. I need it this way because before approving, I need to show a confirmation pop-up so I will only proceed with the workflow state change if the approver clicks yes. And if approver declines, I will show a pop-up to write the reason.
Now, whenever the approver approves it, it shows this error:
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 660, in check_if_latest
self.check_docstatus_transition(tmp.docstatus)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 699, in check_docstatus_transition
raise frappe.DocstatusTransitionError(_("Cannot change docstatus from 1 to 0"))
frappe.exceptions.DocstatusTransitionError: Cannot change docstatus from 1 to 0
This is my custom script:
Additional information of the workflow:
States:
Transitions:
Edit:
The error only shows up if I use the custom script. It’s fine when I approve using default action buttons (the dropdown)