Last active
January 16, 2021 11:51
-
-
Save agritheory/68120813d532fefe88aafbbcc982777d to your computer and use it in GitHub Desktop.
Hook onto the workflow action API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Overriding Whitelisted Methods (in my_app/hooks.py) | |
# ------------------------------ | |
override_whitelisted_methods = { | |
"frappe.model.workflow.apply_workflow": "my_app.workflows.apply_workflow" | |
} | |
# in my_app/workflows.py | |
import frappe | |
from frappe.model.workflow import apply_workflow as model_apply_workflow | |
from six import string_types | |
import json | |
@frappe.whitelist(allow_guest=True) | |
def apply_workflow(doc, action): | |
if isinstance(doc, string_types): | |
doc = frappe._dict(json.loads(doc)) | |
print(doc.name, action) # you can perform other logic here | |
return model_apply_workflow(doc, action) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment