Rushabh Mehta | e67d1fb | 2013-08-05 14:59:54 +0530 | [diff] [blame] | 1 | # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. |
| 2 | # License: GNU General Public License v3. See license.txt |
Rushabh Mehta | 3966f1d | 2012-02-23 12:35:32 +0530 | [diff] [blame] | 3 | |
Anand Doshi | 486f9df | 2012-07-19 13:40:31 +0530 | [diff] [blame] | 4 | from __future__ import unicode_literals |
Rushabh Mehta | 1a35574 | 2012-02-23 11:46:28 +0530 | [diff] [blame] | 5 | """will be called by scheduler""" |
| 6 | |
| 7 | import webnotes |
Anand Doshi | f9e4b16 | 2012-02-28 11:31:46 +0530 | [diff] [blame] | 8 | from webnotes.utils import scheduler |
Rushabh Mehta | 1a35574 | 2012-02-23 11:46:28 +0530 | [diff] [blame] | 9 | |
| 10 | def execute_all(): |
Anand Doshi | f9e4b16 | 2012-02-28 11:31:46 +0530 | [diff] [blame] | 11 | """ |
| 12 | * get support email |
| 13 | * recurring invoice |
| 14 | """ |
Rushabh Mehta | f0018b5 | 2012-08-02 18:03:12 +0530 | [diff] [blame] | 15 | # pull emails |
Rushabh Mehta | 133d752 | 2013-01-15 14:17:31 +0530 | [diff] [blame] | 16 | from support.doctype.support_ticket.get_support_mails import get_support_mails |
Rushabh Mehta | f0018b5 | 2012-08-02 18:03:12 +0530 | [diff] [blame] | 17 | run_fn(get_support_mails) |
Rushabh Mehta | 3169ef0 | 2013-01-15 17:23:23 +0530 | [diff] [blame] | 18 | |
| 19 | from hr.doctype.job_applicant.get_job_applications import get_job_applications |
| 20 | run_fn(get_job_applications) |
Rushabh Mehta | 2e5db35 | 2013-01-16 11:34:26 +0530 | [diff] [blame] | 21 | |
| 22 | from selling.doctype.lead.get_leads import get_leads |
Rushabh Mehta | 1a0b27e | 2013-01-16 12:36:07 +0530 | [diff] [blame] | 23 | run_fn(get_leads) |
Rushabh Mehta | 2e5db35 | 2013-01-16 11:34:26 +0530 | [diff] [blame] | 24 | |
Rushabh Mehta | f0018b5 | 2012-08-02 18:03:12 +0530 | [diff] [blame] | 25 | from webnotes.utils.email_lib.bulk import flush |
| 26 | run_fn(flush) |
Rushabh Mehta | 1a35574 | 2012-02-23 11:46:28 +0530 | [diff] [blame] | 27 | |
| 28 | def execute_daily(): |
Rushabh Mehta | d65ced5 | 2013-07-26 16:05:59 +0530 | [diff] [blame] | 29 | # event reminders |
| 30 | from core.doctype.event.event import send_event_digest |
| 31 | run_fn(send_event_digest) |
| 32 | |
Rushabh Mehta | f0018b5 | 2012-08-02 18:03:12 +0530 | [diff] [blame] | 33 | # email digest |
| 34 | from setup.doctype.email_digest.email_digest import send |
| 35 | run_fn(send) |
| 36 | |
Rushabh Mehta | 48f5f40 | 2012-08-06 14:19:11 +0530 | [diff] [blame] | 37 | # run recurring invoices |
Anand Doshi | 420e1b4 | 2012-11-30 15:11:12 +0530 | [diff] [blame] | 38 | from accounts.doctype.sales_invoice.sales_invoice import manage_recurring_invoices |
Rushabh Mehta | 48f5f40 | 2012-08-06 14:19:11 +0530 | [diff] [blame] | 39 | run_fn(manage_recurring_invoices) |
| 40 | |
Rushabh Mehta | f0018b5 | 2012-08-02 18:03:12 +0530 | [diff] [blame] | 41 | # send bulk emails |
Rushabh Mehta | 52006ca | 2012-08-03 14:15:25 +0530 | [diff] [blame] | 42 | from webnotes.utils.email_lib.bulk import clear_outbox |
Rushabh Mehta | f0018b5 | 2012-08-02 18:03:12 +0530 | [diff] [blame] | 43 | run_fn(clear_outbox) |
Anand Doshi | f9e4b16 | 2012-02-28 11:31:46 +0530 | [diff] [blame] | 44 | |
Rushabh Mehta | 2025084 | 2013-03-07 12:25:21 +0530 | [diff] [blame] | 45 | # daily backup |
Rushabh Mehta | 481d0de | 2013-03-07 12:48:47 +0530 | [diff] [blame] | 46 | from setup.doctype.backup_manager.backup_manager import take_backups_daily |
Anand Doshi | ad6180e | 2013-06-17 11:57:04 +0530 | [diff] [blame] | 47 | run_fn(take_backups_daily) |
Rushabh Mehta | 2025084 | 2013-03-07 12:25:21 +0530 | [diff] [blame] | 48 | |
Nabin Hait | 62d0629 | 2013-05-22 16:19:10 +0530 | [diff] [blame] | 49 | # check reorder level |
| 50 | from stock.utils import reorder_item |
| 51 | run_fn(reorder_item) |
Rushabh Mehta | 1e81479 | 2013-08-07 10:35:11 +0530 | [diff] [blame] | 52 | |
| 53 | # scheduler error |
| 54 | scheduler.report_errors() |
Nabin Hait | 62d0629 | 2013-05-22 16:19:10 +0530 | [diff] [blame] | 55 | |
Anand Doshi | f9e4b16 | 2012-02-28 11:31:46 +0530 | [diff] [blame] | 56 | def execute_weekly(): |
Rushabh Mehta | 481d0de | 2013-03-07 12:48:47 +0530 | [diff] [blame] | 57 | from setup.doctype.backup_manager.backup_manager import take_backups_weekly |
Anand Doshi | ad6180e | 2013-06-17 11:57:04 +0530 | [diff] [blame] | 58 | run_fn(take_backups_weekly) |
Anand Doshi | f9e4b16 | 2012-02-28 11:31:46 +0530 | [diff] [blame] | 59 | |
| 60 | def execute_monthly(): |
| 61 | pass |
| 62 | |
| 63 | def execute_hourly(): |
| 64 | pass |
Rushabh Mehta | f0018b5 | 2012-08-02 18:03:12 +0530 | [diff] [blame] | 65 | |
| 66 | def run_fn(fn): |
| 67 | try: |
| 68 | fn() |
| 69 | except Exception, e: |
| 70 | scheduler.log(fn.func_name) |