Override all save function in all doctype

Hello, any method to override all “before save” method on every doctype?
Let say, I want to create pop up (done/success) when I press save button on the new item (doctype).

since all doctype inherit from Document, maybe create your custom Document class which inherits Document itself. Then make all your docs inherits it instead.

Never done this myself though.

Have you tried hooks?


i think that is what i need,
do you have tutorial step by step to create/setting hook?

in erpnext/hooks.py

Ex: You need to call a method when before save Sales Invoice.
Assuming you have a custom app, call custom_erp

doc_events = {
	"Sales Invoice": {
		"before_save": "custom_erp.filename.method_name"

Your method

def method_name(doc, method):
    # doc is sales invoice doc

wow great thank you very much,
any idea how to call javascript method inside python?
i want to call alert in hook after_save

try this:


thank you so much, i will try it