Hello,
I want to add background job. But somehow it is not coming in background job page & hence it is not working.
import frappe
def message():
frappe.msgprint("Inside")
print("Completed Schedule Task.")
@frappe.whitelist()
def on_submit(docname,time):
# Calculate the delay in seconds between now and the schedule_date_time
schedule_time = datetime.strptime(time, '%Y-%m-%d %H:%M:%S')
one_day_earlier = schedule_time - timedelta(days=1)
hours = one_day_earlier.hour
minutes = one_day_earlier.minute
now = now_datetime()
delay = (schedule_time - now).total_seconds()
if delay > 0:
frappe.enqueue(
message,
now=False,
queue="default",
timeout=delay,
enqueue_after_commit=True,
at_front=True
)
frappe.msgprint("Started")