From c15a3bd379a55e25d2b027d58c3e48b12a8639fe Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 19 Sep 2017 12:53:01 +0530 Subject: [PATCH] [fix] Subscription patch broken if reference document has been cancelled --- .../patches/v8_7/make_subscription_from_recurring_data.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/patches/v8_7/make_subscription_from_recurring_data.py b/erpnext/patches/v8_7/make_subscription_from_recurring_data.py index 89830a22f8..ab0fc121fc 100644 --- a/erpnext/patches/v8_7/make_subscription_from_recurring_data.py +++ b/erpnext/patches/v8_7/make_subscription_from_recurring_data.py @@ -20,8 +20,8 @@ def execute(): def get_data(doctype): return frappe.db.sql(""" select name, from_date, end_date, recurring_type,recurring_id, next_date, notify_by_email, notification_email_address, recurring_print_format, - repeat_on_day_of_month, submit_on_creation - from `tab{0}` where is_recurring = 1 and next_date >= %s + repeat_on_day_of_month, submit_on_creation, docstatus + from `tab{0}` where is_recurring = 1 and next_date >= %s and docstatus < 2 """.format(doctype), today(), as_dict=1) def make_subscription(doctype, data): @@ -39,4 +39,5 @@ def make_subscription(doctype, data): 'submit_on_creation': data.submit_on_creation }).insert(ignore_permissions=True) - doc.submit() \ No newline at end of file + if data.docstatus == 1: + doc.submit() \ No newline at end of file