From b9460ed22c96b1d35186aea9555cf95f7b383987 Mon Sep 17 00:00:00 2001 From: 0Pranav Date: Tue, 19 Nov 2019 10:46:07 +0530 Subject: [PATCH] switched ORM methods for single SQL query --- erpnext/selling/doctype/quotation/quotation.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index 82e98277ee..9903884b88 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -186,12 +186,10 @@ def _make_sales_order(source_name, target_doc=None, ignore_permissions=False): return doclist def set_expired_status(): - quotations = frappe.get_all("Quotation") - for quotation in quotations: - quotation = frappe.get_doc("Quotation",quotation.name) - if quotation.valid_till and getdate(quotation.valid_till) < getdate(nowdate()): - frappe.db.set(quotation,'status','Expired') - frappe.db.commit() + from datetime import date + DATE_FORMAT = "%Y%m%d" # For converting python date to SQL comparable date + today = date.today().strftime(DATE_FORMAT) + frappe.db.sql("UPDATE tabQuotation SET status = 'Expired' WHERE valid_till < " + today) @frappe.whitelist() def make_sales_invoice(source_name, target_doc=None):