From 7580723ab38b46a1ae85ed94bb5e0d2f80a0427b Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 2 Jul 2015 14:41:27 +0530 Subject: [PATCH] Recurring docs should not consider Stopped documents and should be scheduled for hourly --- erpnext/controllers/recurring_document.py | 8 +++++--- erpnext/hooks.py | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/erpnext/controllers/recurring_document.py b/erpnext/controllers/recurring_document.py index 8c8af23b58..f9ab50965c 100644 --- a/erpnext/controllers/recurring_document.py +++ b/erpnext/controllers/recurring_document.py @@ -33,11 +33,13 @@ def manage_recurring_documents(doctype, next_date=None, commit=True): next_date = next_date or nowdate() date_field = date_field_map[doctype] + + condition = " and ifnull(status, '') != 'Stopped'" if doctype in ("Sales Order", "Purchase Order") else "" recurring_documents = frappe.db.sql("""select name, recurring_id - from `tab{}` where ifnull(is_recurring, 0)=1 - and docstatus=1 and next_date='{}' - and next_date <= ifnull(end_date, '2199-12-31')""".format(doctype, next_date)) + from `tab{0}` where ifnull(is_recurring, 0)=1 + and docstatus=1 and next_date=%s + and next_date <= ifnull(end_date, '2199-12-31') {1}""".format(doctype, condition), next_date) exception_list = [] for ref_document, recurring_id in recurring_documents: diff --git a/erpnext/hooks.py b/erpnext/hooks.py index d9262d483c..f84951b1c3 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -78,8 +78,10 @@ doc_events = { } scheduler_events = { + "hourly": [ + "erpnext.controllers.recurring_document.create_recurring_documents" + ], "daily": [ - "erpnext.controllers.recurring_document.create_recurring_documents", "erpnext.stock.reorder_item.reorder_item", "erpnext.setup.doctype.email_digest.email_digest.send", "erpnext.support.doctype.issue.issue.auto_close_tickets",