How to display Sales Order List after saving an order

Hi all, I need to display sales order list after SAVING an order. I am not sure how to do it?
we have only refresh, onload, validate events available. where would I put my
frappe.set_route(“List”,“Sales Order”) line. Any help. Thanks

Hi try looking at Document Events under Hooks.py, you can manipulate events after creation, validation or depends on what you like.

Documentation here:
https://frappe.github.io/frappe/user/en/guides/basics/hooks

Thank you johnskywalker I will look into it, your help much appreciated

but how do I invoke frappe.set_route (client side) from hooks.py which executes server-side method. Is there a server-side frappe method to navigate to “List”, “Sales Order” after saving “New Sales Order”?
Simply put, I want the on_update to take me to Order Line List, how can I achieve that?

In ERPNext, after clicking Save in Sales Order, the user is directed to Sales Order List. How can I do the same thing with a custom sales order doc - in frappe?

Hi ! after creating a custom sales order doc, did you see python files in your directory?

Hi yes, and the hooks.py works in that I get msgprint(“here”) from python

ok in python files you do it like this

class YOUR_DOCTYPE(Document):
def autoname(self):
pass

def validate(self):
pass

def on_submit(self):
pass

def on_cancel(self):
pass

Ok had the class Sales Order, now I added the events you mentioned. I must say that I do not submit the order but save it only. So docstatus remains 0,I guess on_submit will not fire in this case. So I have only validate event to do cur_frm.set_route(“List”,“Sales Order”) after successful validation. is this a correct approach?

yes you are right

Thank you for the help Johnskywalker,

you are welcome :slight_smile: