How to trigger something when save or submit is clicked in a doctype?

Ohh thanks it is working.
What is the difference between adding a function through hooks and through the docname.py