blob: 28ff2aef1ef3ab2e7dd3c8d7f5360c346b08e351 [file] [log] [blame]
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05301# ERPNext - web based ERP (http://erpnext.com)
2# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
Anand Doshi486f9df2012-07-19 13:40:31 +053017from __future__ import unicode_literals
Rushabh Mehta1a355742012-02-23 11:46:28 +053018"""will be called by scheduler"""
19
20import webnotes
Anand Doshif9e4b162012-02-28 11:31:46 +053021from webnotes.utils import scheduler
Rushabh Mehta1a355742012-02-23 11:46:28 +053022
23def execute_all():
Anand Doshif9e4b162012-02-28 11:31:46 +053024 """
25 * get support email
26 * recurring invoice
27 """
Rushabh Mehtaf0018b52012-08-02 18:03:12 +053028 # pull emails
Rushabh Mehta133d7522013-01-15 14:17:31 +053029 from support.doctype.support_ticket.get_support_mails import get_support_mails
Rushabh Mehtaf0018b52012-08-02 18:03:12 +053030 run_fn(get_support_mails)
Rushabh Mehta3169ef02013-01-15 17:23:23 +053031
32 from hr.doctype.job_applicant.get_job_applications import get_job_applications
33 run_fn(get_job_applications)
Rushabh Mehta2e5db352013-01-16 11:34:26 +053034
35 from selling.doctype.lead.get_leads import get_leads
Rushabh Mehta1a0b27e2013-01-16 12:36:07 +053036 run_fn(get_leads)
Rushabh Mehta2e5db352013-01-16 11:34:26 +053037
Rushabh Mehtaf0018b52012-08-02 18:03:12 +053038 from webnotes.utils.email_lib.bulk import flush
39 run_fn(flush)
Rushabh Mehta1a355742012-02-23 11:46:28 +053040
41def execute_daily():
Rushabh Mehtad65ced52013-07-26 16:05:59 +053042 # event reminders
43 from core.doctype.event.event import send_event_digest
44 run_fn(send_event_digest)
45
Rushabh Mehtaf0018b52012-08-02 18:03:12 +053046 # email digest
47 from setup.doctype.email_digest.email_digest import send
48 run_fn(send)
49
Rushabh Mehta48f5f402012-08-06 14:19:11 +053050 # run recurring invoices
Anand Doshi420e1b42012-11-30 15:11:12 +053051 from accounts.doctype.sales_invoice.sales_invoice import manage_recurring_invoices
Rushabh Mehta48f5f402012-08-06 14:19:11 +053052 run_fn(manage_recurring_invoices)
53
Rushabh Mehtaf0018b52012-08-02 18:03:12 +053054 # send bulk emails
Rushabh Mehta52006ca2012-08-03 14:15:25 +053055 from webnotes.utils.email_lib.bulk import clear_outbox
Rushabh Mehtaf0018b52012-08-02 18:03:12 +053056 run_fn(clear_outbox)
Anand Doshif9e4b162012-02-28 11:31:46 +053057
Rushabh Mehta20250842013-03-07 12:25:21 +053058 # daily backup
Rushabh Mehta481d0de2013-03-07 12:48:47 +053059 from setup.doctype.backup_manager.backup_manager import take_backups_daily
Anand Doshiad6180e2013-06-17 11:57:04 +053060 run_fn(take_backups_daily)
Rushabh Mehta20250842013-03-07 12:25:21 +053061
Nabin Hait62d06292013-05-22 16:19:10 +053062 # check reorder level
63 from stock.utils import reorder_item
64 run_fn(reorder_item)
65
Anand Doshif9e4b162012-02-28 11:31:46 +053066def execute_weekly():
Rushabh Mehta481d0de2013-03-07 12:48:47 +053067 from setup.doctype.backup_manager.backup_manager import take_backups_weekly
Anand Doshiad6180e2013-06-17 11:57:04 +053068 run_fn(take_backups_weekly)
Anand Doshif9e4b162012-02-28 11:31:46 +053069
70def execute_monthly():
71 pass
72
73def execute_hourly():
74 pass
Rushabh Mehtaf0018b52012-08-02 18:03:12 +053075
76def run_fn(fn):
77 try:
78 fn()
79 except Exception, e:
80 scheduler.log(fn.func_name)