In [1]: from custom_app.module_name import build_my_thing
In [2]: build_my_thing()
In [3]: sales_invoice = frappe.get_doc("Sales Invoice", "SINV-00165")
In [4]: sales_invoice.shoutout()
Yay!
In [5]: sales_invoice.cancel()
Yay!
@revant_one I have been looking for such a method for a while. This is great pointer.
Quick Question - How is this loaded in the ERPNext context? Would you call build_my_thing() function on load of the core doctype? I’m no able to grasp when the bench would load the overridden function…
Thanks @revant_one I tried using befoe_insert and onload. It works, but works inconsistently. Sometimes the custom method is called, but then other times, original method is called…doctype needs to be reloaded to call the custom method again…I dont know when it happens/ any thoughts?
Thanks.
Other form that you can use to override methods in an application is call build_my_thing function at the end of hooks.py file. Specially userful when the method is in a class controller. We are testing that solution but apparently it works.
@sanjay yes I tried, I can able to override the whitelisted erpnext method from custom app via hooks.py and also a method inside the class, but i could not able to override the python method
Hi @netchampfaris I need to use override_doctype_class hook but not sure if I’m missing something because it’s not working for me. The method metioned in the override_doctype_class is not reached. Could you please help?