ERPNext V15 custom Code in doctype

It’s tricky to develop but check the example in the reference: