From 79a01561d52326c35dad4362007f0ef2c9d5cfaf Mon Sep 17 00:00:00 2001 From: tundebabzy Date: Sat, 3 Mar 2018 07:39:44 +0100 Subject: [PATCH] enhancement: do nothing if `cancel_sbscription` is called for cancelled subscription --- .../doctype/subscriptions/subscriptions.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/doctype/subscriptions/subscriptions.py b/erpnext/accounts/doctype/subscriptions/subscriptions.py index 6264972a98..7796daa8e3 100644 --- a/erpnext/accounts/doctype/subscriptions/subscriptions.py +++ b/erpnext/accounts/doctype/subscriptions/subscriptions.py @@ -396,13 +396,14 @@ class Subscriptions(Document): This sets the subscription as cancelled. It will stop invoices from being generated but it will not affect already created invoices. """ - to_generate_invoice = True if self.status == 'Active' else False - to_prorate = frappe.db.get_single_value('Subscription Settings', 'prorate') - self.status = 'Canceled' - self.cancelation_date = nowdate() - if to_generate_invoice: - self.generate_invoice(prorate=to_prorate) - self.save() + if self.status != 'Canceled': + to_generate_invoice = True if self.status == 'Active' else False + to_prorate = frappe.db.get_single_value('Subscription Settings', 'prorate') + self.status = 'Canceled' + self.cancelation_date = nowdate() + if to_generate_invoice: + self.generate_invoice(prorate=to_prorate) + self.save() def restart_subscription(self): """