feat: Added check for no end date and refactored query
diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py
index ca78e5e..221df41 100755
--- a/erpnext/projects/doctype/task/task.py
+++ b/erpnext/projects/doctype/task/task.py
@@ -160,7 +160,7 @@
 		self.update_nsm_model()
 
 	def update_status(self):
-		if self.status not in ('Cancelled', 'Closed'):
+		if self.status not in ('Cancelled', 'Closed') and self.exp_end_date:
 			from datetime import datetime
 			if self.exp_end_date < datetime.now().date():
 				self.date = 'Overdue'
@@ -193,7 +193,7 @@
 		task.save()
 
 def set_tasks_as_overdue():
-	tasks = frappe.get_all("Task")
+	tasks = frappe.get_all("Task", filters={'status':['not in',['Cancelled', 'Closed']]})
 	for task in tasks:
 		frappe.get_doc("Task", task.name).update_status()