Created
November 27, 2019 13:08
-
-
Save agritheory/2070d04fd899e2fff2cb9c135bdacd8c to your computer and use it in GitHub Desktop.
Basic document hook (snippets)
This file contains hidden or 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
doc_events = { | |
"Sales Order": { | |
"on_submit": "my_custom_app.workflows.make_stock_entry_on_so_submit" | |
}, | |
"on_cancel": "my_custom_app.workflows.cancel_stock_entry_on_so_cancel" | |
} | |
} |
This file contains hidden or 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
# located in the same directory of my_custom_app as hooks.py | |
@frappe.whitelist() | |
def make_stock_entry_on_so_submit(so, method): # required arguments | |
doc = frappe.new_doc("Stock Entry") | |
# move data to your stock entry record from sales order | |
doc.save() | |
doc.submit() | |
so.stock_entry = doc.name # so.stock_entry is a custom field | |
return so | |
@frappe.whitelist() | |
def cancel_stock_entry_on_so_cancel(so, method): # required arguments | |
doc = frappe.get_doc("Stock Entry", so.stock_entry) # decide how you want to store a related stock entry, probably a custom field | |
doc.cancel() | |
so.stock_entry = "" | |
return so |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment