Hi @lateliercom,
If you want to add your scenario then you have a create a custom app and then set it hook.py file and call it.
Please check the references:
- Create an App
- ERPNext/Frappe: Creating & Installing Custom Apps
- Fixtures and Doc Events (using hooks) in Frappe Framework!
- Overriding Base Methods in ERPNext with a Custom App
Also check the hook concept.
I hope this helps.
Thank You!