Hello,
I added an on_submit
event to the sales invoice to perform an action, and if this action fails, I throw an error to prevent the document from being submitted.
This works perfectly on my local setup, but when I update it in Frappe Cloud, it’s not functioning as expected.
The issue in Frappe Cloud is that when I attempt to submit the document and the action fails, it throws an error as it should. However, when I refresh the document, it is automatically submitted.
Why does this issue occur in Frappe Cloud but not in my local environment?
hooks.py
doc_events = {
“Sales Invoice”: {
“on_submit”: “nextpty_customization.e_invoice.e_invoice_apis.check_for_auto_e_invoice”,
}
}
raise exception and show error message
frappe.msgprint(f"“”Message: {response[‘message’]}
Description: {response[‘description’]}
View E-Invoice Logs“”", “E-Invoice Creation Failed.”, indicator=‘red’, raise_exception=True)