From 754c43f6c3afb918f4fa60b971994a31ef97f782 Mon Sep 17 00:00:00 2001 From: 0Pranav Date: Mon, 25 Nov 2019 14:27:43 +0530 Subject: [PATCH] fix set_expired_status method --- erpnext/selling/doctype/quotation/quotation.py | 4 ++-- erpnext/selling/doctype/quotation/test_quotation.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index b63c2e1fef..2ce01aa4af 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -186,8 +186,8 @@ def _make_sales_order(source_name, target_doc=None, ignore_permissions=False): return doclist def set_expired_status(): - frappe.db.sql("""UPDATE `tabQuotation` SET status = 'Expired' - WHERE 'valid_till' < %s""", (nowdate())) + frappe.db.sql("""UPDATE `tabQuotation` SET `status` = 'Expired' + WHERE `status` != "Expired" AND `valid_till` < %s""", (nowdate())) frappe.db.commit() @frappe.whitelist() diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py index 7739e3e623..b450c29a87 100644 --- a/erpnext/selling/doctype/quotation/test_quotation.py +++ b/erpnext/selling/doctype/quotation/test_quotation.py @@ -218,9 +218,9 @@ class TestQuotation(unittest.TestCase): ] yesterday = getdate(nowdate()) - datetime.timedelta(days=1) expired_quotation = make_quotation(item_list=quotation_item) - # Manually set valid till date to bypass validation expired_quotation.valid_till = yesterday expired_quotation.save() + # Call schedular method set_expired_status() self.assertEqual(expired_quotation.status,"Expired")