Recurring docs should not consider Stopped documents and should be scheduled for hourly
diff --git a/erpnext/controllers/recurring_document.py b/erpnext/controllers/recurring_document.py
index 8c8af23..f9ab509 100644
--- a/erpnext/controllers/recurring_document.py
+++ b/erpnext/controllers/recurring_document.py
@@ -33,11 +33,13 @@
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 d9262d4..f84951b 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -78,8 +78,10 @@
}
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",