blob: 0cf06026d624965b7cf9e7f42b69edf40f5c478e [file] [log] [blame]
Rushabh Mehtaad45e312013-11-20 12:59:58 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
Rushabh Mehtae67d1fb2013-08-05 14:59:54 +05302# License: GNU General Public License v3. See license.txt
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05303
Anand Doshi486f9df2012-07-19 13:40:31 +05304from __future__ import unicode_literals
Rushabh Mehta1a355742012-02-23 11:46:28 +05305"""will be called by scheduler"""
6
7import webnotes
Anand Doshif9e4b162012-02-28 11:31:46 +05308from webnotes.utils import scheduler
Rushabh Mehta1a355742012-02-23 11:46:28 +05309
10def execute_all():
Anand Doshif9e4b162012-02-28 11:31:46 +053011 """
12 * get support email
13 * recurring invoice
14 """
Rushabh Mehtaf0018b52012-08-02 18:03:12 +053015 # pull emails
Rushabh Mehta133d7522013-01-15 14:17:31 +053016 from support.doctype.support_ticket.get_support_mails import get_support_mails
Rushabh Mehtaf0018b52012-08-02 18:03:12 +053017 run_fn(get_support_mails)
Rushabh Mehta3169ef02013-01-15 17:23:23 +053018
19 from hr.doctype.job_applicant.get_job_applications import get_job_applications
20 run_fn(get_job_applications)
Rushabh Mehta2e5db352013-01-16 11:34:26 +053021
22 from selling.doctype.lead.get_leads import get_leads
Rushabh Mehta1a0b27e2013-01-16 12:36:07 +053023 run_fn(get_leads)
Rushabh Mehta2e5db352013-01-16 11:34:26 +053024
Rushabh Mehtaf0018b52012-08-02 18:03:12 +053025 from webnotes.utils.email_lib.bulk import flush
26 run_fn(flush)
Rushabh Mehta1a355742012-02-23 11:46:28 +053027
28def execute_daily():
Rushabh Mehtad65ced52013-07-26 16:05:59 +053029 # event reminders
30 from core.doctype.event.event import send_event_digest
31 run_fn(send_event_digest)
32
Rushabh Mehta04cc5152013-11-18 13:22:07 +053033 # clear daily event notifications
34 from core.doctype.notification_count.notification_count import delete_notification_count_for
35 delete_notification_count_for("Event")
36
Rushabh Mehta48f5f402012-08-06 14:19:11 +053037 # run recurring invoices
Anand Doshi420e1b42012-11-30 15:11:12 +053038 from accounts.doctype.sales_invoice.sales_invoice import manage_recurring_invoices
Rushabh Mehta48f5f402012-08-06 14:19:11 +053039 run_fn(manage_recurring_invoices)
40
Rushabh Mehtaf0018b52012-08-02 18:03:12 +053041 # send bulk emails
Rushabh Mehta52006ca2012-08-03 14:15:25 +053042 from webnotes.utils.email_lib.bulk import clear_outbox
Rushabh Mehtaf0018b52012-08-02 18:03:12 +053043 run_fn(clear_outbox)
Anand Doshif9e4b162012-02-28 11:31:46 +053044
Rushabh Mehta20250842013-03-07 12:25:21 +053045 # daily backup
Rushabh Mehta481d0de2013-03-07 12:48:47 +053046 from setup.doctype.backup_manager.backup_manager import take_backups_daily
Anand Doshiad6180e2013-06-17 11:57:04 +053047 run_fn(take_backups_daily)
Rushabh Mehta20250842013-03-07 12:25:21 +053048
Nabin Hait62d06292013-05-22 16:19:10 +053049 # check reorder level
50 from stock.utils import reorder_item
51 run_fn(reorder_item)
Anand Doshib0636ed2013-12-16 13:51:09 +053052
53 # email digest
54 from setup.doctype.email_digest.email_digest import send
55 run_fn(send)
Nabin Hait10fd91c2014-01-07 16:18:41 +053056
57 # auto close support tickets
58 from support.doctype.support_ticket.support_ticket import auto_close_tickets
59 run_fn(auto_close_tickets)
Rushabh Mehta1e814792013-08-07 10:35:11 +053060
Anand Doshif9e4b162012-02-28 11:31:46 +053061def execute_weekly():
Rushabh Mehta481d0de2013-03-07 12:48:47 +053062 from setup.doctype.backup_manager.backup_manager import take_backups_weekly
Anand Doshiad6180e2013-06-17 11:57:04 +053063 run_fn(take_backups_weekly)
Anand Doshif9e4b162012-02-28 11:31:46 +053064
65def execute_monthly():
66 pass
67
68def execute_hourly():
69 pass
Rushabh Mehtaf0018b52012-08-02 18:03:12 +053070
71def run_fn(fn):
72 try:
73 fn()
74 except Exception, e:
75 scheduler.log(fn.func_name)