Now, I am stuck at erpnext python code overriding?
In some cases we can use hooks before insert, after insert to write own python code, but this is not possible for current case as data is coming from local storage.
Is it possible to override exiting python methods?
How to access local storage in python?
@rmehta The complete feature will be enable bold fields in pos.
For this current fix, we just need to update below code. and loop data (data is local storage customer list here)
Please advise on it.
In : from custom_app.module_name import build_my_thing
In : build_my_thing()
In : sales_invoice = frappe.get_doc("Sales Invoice", "SINV-00165")
In : sales_invoice.shoutout()
In : sales_invoice.cancel()
@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?
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.
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?