This is my workflow
This is the last workflow state (“Unpaid”)
I want when the Payment is clicked and Payment entry is made, then somehow the status is changed to “Paid”, either of status, or approval_status or workflow_state
I just want the “Unpaid” status to change to “Paid” after the Payment entry is made.
Anyone help ?
Hello,
You can add one more state that is Paid
1 Then write a server script on Payment Entry to track the amount to be paid against this Expense Claim. When it reaches 100%, you can write another logic to change status to Paid.
2 Or If it is paid fully every time write script in Payment Entry to change Status of Expense Claim after submitting it.
3 Or if you want to make it Paid even if less amount is paid you can add it in Transition to manually change the Status.
I used below step to solve this issue
-
added this Paid Status, with checkbox tiicked “is Optional State”
-
changed payment_entry.py file, changed the on_submit code, added this, so that “workflow_status” changes to “Paid”
# -----------------------------------------------------------------
for reference in self.references:
if reference.reference_doctype == "Expense Claim":
expense_claim = frappe.get_doc("Expense Claim", reference.reference_name)
expense_claim.workflow_state = "Paid"
expense_claim.save()
frappe.db.commit()
# ------------------------------------------------------------------
- Commented this code in workflow.py, because it was not allowing to change the state (one of the solution i found, maybe wrong, but worked for me)
Done : now when you click on create then submit the Payment entry, “workflow_state” changes to “Paid”
1 Like