Overriding Class methods

Hello All,

Is there is any way to override core Class Method (non whitelisted)
I am trying to override get_gl_entries() method of ExpenseClaim class in expense_claim.py file using hooks.py

But I didn’t got any concrete solution for that.

As overriding of whitelisted is possible by setting in configuration in hooks.py file
override_whitelisted_methods = {
** “frappe.desk.doctype.event.event.get_events”: “newapp.event.get_events”**
}

**Any thing available for non-whitelisted like above. **

Please provide solution for that.

Thank You

Explain what you are trying to achieve, maybe there is a more generic way of doing that.

Hi Rushabh,
Currently in ERPNext core Employee is part of Expense Claim table (form), but one of our company does the claims little differently. One persons is responsibility to enters Expense claim for all the employees against a Project. Since multiple Employee work on same Project 1 and only 1 Expense claim record should be created for a Project in a month with multiple Employee entry in Expense Claim Details table (One2Many).

To achieve the above I created a field Employee in Expense Expense Details through UI. Now just by doing this the Journal entries will not be reflected correctly so I am trying to override get_gl_entries(). I know for the fact that all non Class functions can be overridden in Hooks.py (using whitelisted method). Since get_gl_entries() belongs to ExpenseClaim Class I am not able to override this function, presuming Class functions cannot be overridden.

This is purely because we have 4 company and 4 db for each company (using multi-tenant of erpnext). This change is specific to only one company.

Thanks.

Another approach would be Is Single DocType or a Page on which you can let the Data Entry Employee enter expense claims. Once all the data is in this Single DT or Page programatically generate standard Expense Claim Entries using frappe.new_doc().

Refer Production Planning Tool and Data Import Tool.