hook to hourly scheduler

This commit is contained in:
tundebabzy 2018-03-01 11:33:03 +01:00
parent 78fb12663a
commit 0ec445214c
2 changed files with 21 additions and 1 deletions

View File

@ -290,6 +290,25 @@ class Subscriptions(Document):
self.save()
def process_all():
subscriptions = get_all_subscriptions()
for subscription in subscriptions:
process(subscription)
def get_all_subscriptions():
return frappe.db.sql(
'select name from `tabSubscriptions` where status != "Canceled"',
as_dict=1
)
def process(data):
if data:
subscription = frappe.get_doc('Subscriptions', data['name'])
subscription.process()
@frappe.whitelist()
def cancel_subscription(name):
subscription = frappe.get_doc('Subscriptions', name)

View File

@ -218,7 +218,8 @@ doc_events = {
scheduler_events = {
"hourly": [
"erpnext.accounts.doctype.subscription.subscription.make_subscription_entry",
'erpnext.hr.doctype.daily_work_summary_group.daily_work_summary_group.trigger_emails'
'erpnext.hr.doctype.daily_work_summary_group.daily_work_summary_group.trigger_emails',
"erpnext.assets.doctype.subscriptions.subscriptions.process_all"
],
"daily": [
"erpnext.stock.reorder_item.reorder_item",