diff --git a/erpnext/accounts/doctype/subscriptions/subscriptions.py b/erpnext/accounts/doctype/subscriptions/subscriptions.py index ec7d1bba247..7d11ad53f13 100644 --- a/erpnext/accounts/doctype/subscriptions/subscriptions.py +++ b/erpnext/accounts/doctype/subscriptions/subscriptions.py @@ -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) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index a2f7e5667fc..999f9aabdf5 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -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",