[fix] check for null date fields (#11334)
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 7ab0e2c..3d01297 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 @@
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