Rajvi
December 23, 2022, 7:32am
9
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.
ISSUES:
[Screenshot from 2022-08-12 12-19-14]
[Screenshot from 2022-08-12 12-19-26]
Once we set the email campaign we can view the list view like the one given below screenshot.
Even After the end date passes the email is sent to the customers.
In the status, it just shows as it was “In Progress” or “Scheduled”.
No update we get an email sent or not sent.
Nothing gets triggered after the date passes.
So mass mailing system does not work in an email campaign.
For now, we are only able to se…
Email Campaign are not being sent. The status is stuck at “In Progress” for some days now.
How do I begin yo troubleshoot this?
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,
ToDo:“customapp.overides.customToDo”
In python,
from erpnext.erpnext.module.doctype.doctype_py Import ToDo
class customToDo(ToDo):
def validate(self):
super().validate()
#your code
Here super is to run the core
Rajvi
December 27, 2022, 4:35am
11
This override Class method. I want to override core function which is also not whitelisted.
1 Like
Aghiles
February 26, 2025, 1:25pm
13
Hello @Rajvi ,
I’m facing the same problem, did you find any solution ?
If you really have to override, the practice is to do this :
override the whole class which contains the code of that function or method
inside the overrided code → put your custom code inside that function or method
by doing this the system will use your overrided class and your custom code inside the override file
@Rajvi Did you find any solution, I have same task
Recently i found a solution:
Suppose we have a function send_mail in email_campaign.py
path: apps/erpnext/erpnext/crm/doctype/email_campaign/email_campaign.py
there is a method send_mail which is not whitelisted and not under any class
Override steps:
Create a .py file in your custom app and do changes in send_mail function
Goto __ init __.py file add paths like this
Now it will override the send_mail function @Rajvi @Aghiles
1 Like
Can you please help me on same?
yes , you can do the same thing with other method which is not whitelisted or not under class.
yes , you can do the same thing with other method which is not whitelisted or not under class.
Thanks for sharing solution
But this monkey override will apply on the global
Erpnext for all sites not only the site where the custom app have the override
There is solution for it
can you please explain a bit more ??
you could check for the site within the custom app?
i mean this override apply on the global erpnext code for all sites
not only the site where override is made
from frappe.utils import cstr
site_name = cstr(frappe.local.site)
you can use this to check current site and based on this add your condition
@Vipul_Kumar Not worked, i tried still calling core method ,
method i want to override ( SCHEDULER method) :
bench execute: erpnext.stock.reorder_item.reorder_item
can you please share your code or any reference
@Vipul_Kumar
Yes sure
init file:
overided file:
i am performing method like this:bench execute erpnext.stock.reorder_item.reorder_item
erpnext hooks.py
error log i get: