From d6e67ce123ef5f89352cfcf5af8ccd0f41edd60b Mon Sep 17 00:00:00 2001 From: Saurabh Date: Wed, 25 Oct 2017 17:44:22 +0530 Subject: [PATCH] [fix] check for null date fields (#11334) --- ...hedule_date_for_material_request_and_purchase_order.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/erpnext/patches/v9_0/set_schedule_date_for_material_request_and_purchase_order.py b/erpnext/patches/v9_0/set_schedule_date_for_material_request_and_purchase_order.py index 7ab0e2ca83f..3d012978fab 100644 --- a/erpnext/patches/v9_0/set_schedule_date_for_material_request_and_purchase_order.py +++ b/erpnext/patches/v9_0/set_schedule_date_for_material_request_and_purchase_order.py @@ -17,6 +17,8 @@ def execute(): doc = frappe.get_doc(doctype, record) if doc.items: if not doc.schedule_date: - min_schedule_date = min([d.schedule_date for d in doc.items]) - frappe.db.set_value(doctype, record, - "schedule_date", min_schedule_date, update_modified=False) \ No newline at end of file + schedule_dates = [d.schedule_date for d in doc.items if d.schedule_date] + if len(schedule_dates) > 0: + min_schedule_date = min(schedule_dates) + frappe.db.set_value(doctype, record, + "schedule_date", min_schedule_date, update_modified=False) \ No newline at end of file