How can I override method of core doctype which is not class method or whitelisted method?

Hello Everyone

I want to override method which not whitelisted or not class method. I couldn’t get any solution for this till now.
In we can override doctype class method and doctype whitelisted method with using override_doctype_class and override_whitelisted_methods. but we cannot override a method which is not any of this.

Can anyone help me solving this ?

1 Like

Please explain bit more what type of method and which method or from where you’re trying to override.


Option - 1 : Check that in standard code by which function is calling that method which is already in the class.

Once you find the method which is in the class and calling the method you want to override, write the override code on the method which is in class to achieve, what you want to do.

Option - 2 : Copy the full code of standard method which is outside of class and not whitelisted. Use that code in your own method with overrides you want.

This method is daily scheduler_events which is calling from ERPNext and placed in Email Campaign Doctype. I want to override it in custom app.

This method is not called by any class of doctype.I want to Override ERPNext scheduler events which is in

Ok but why you want to override it ? I’m asking you as I haven’t done this but if you have specific task or something where you need to customise, update, add something in that logic I’ll try and let you know.

I just want to Override ERPNext scheduler events. Let me know if you find something.

Why do you want to override? What is the actual problem you want to solve? Maybe there is another approach to solve the situation?

hello @moe01325
In Email Campaign , there is set_email_campaign_status method which runs daily as it is in schedular events. But this method has error as it is not updating status in database. And because of this issue Email Campaign is not working. So I want to override this method to solve this by saving updated status in database.

Earlier Email Campaign issue is discussed. But there was no solution.

So I have checked core methods and found error in this method which is responsible for this issue.

Call the path in hooks. And in that python import the core class.

In hooks,

In python,
from erpnext.erpnext.module.doctype.doctype_py Import ToDo

class customToDo(ToDo):
def validate(self):
#your code

Here super is to run the core

This override Class method. I want to override core function which is also not whitelisted.

Try Monkey Patch!