Try ERPNext Buy Support Partners Foundation

Overriding class in erpnext

Hello

I want to override one method “pl_must_have_cost_center” in gl_entry.py. So that it takes my custom app’s method and doesn’t execute from gl_entry.py file.

I have found the solution of “override_doctype_class” in hooks.py. But it is not working. I am using frappe V12.

Instantiating and Object is done through f/w frappe. so method you have mentioned is instance method through hooks you can write functions you want to execute but it will execute the “pl_must_have_cost_center” as well since it is not actually overriding but executes sequence of methods on that object and if in first invoke of erp method there are Raise Exceptions it will not come down to your method
We could have writechild class overriding that method but how do we invoke object of child class which is not customisable so may e you have to change in erp itself

Yes. But can’t change method in ErpNext, as if we update to new version, these changes will be lost.
Has anyone faced such an issue?

I might be mistaken, but I believe override_doctype_class is a new feature in v13.

hmm… it is not working in V12