Validation added to prevent task being closed with open dependent tasks
diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py
index 7229203..fcd756b 100644
--- a/erpnext/projects/doctype/task/task.py
+++ b/erpnext/projects/doctype/task/task.py
@@ -28,10 +28,7 @@
def validate(self):
self.validate_dates()
-
- if self.status!=self.get_db_value("status") and self.status == "Closed":
- from frappe.desk.form.assign_to import clear
- clear(self.doctype, self.name)
+ self.validate_status()
def validate_dates(self):
if self.exp_start_date and self.exp_end_date and getdate(self.exp_start_date) > getdate(self.exp_end_date):
@@ -40,6 +37,15 @@
if self.act_start_date and self.act_end_date and getdate(self.act_start_date) > getdate(self.act_end_date):
frappe.throw(_("'Actual Start Date' can not be greater than 'Actual End Date'"))
+ def validate_status(self):
+ if self.status!=self.get_db_value("status") and self.status == "Closed":
+ for d in self.depends_on:
+ if frappe.db.get_value("Task", d.task, "status") != "Closed":
+ frappe.throw(_("Cannot close task as its dependant task {0} is not closed.").format(d.task))
+
+ from frappe.desk.form.assign_to import clear
+ clear(self.doctype, self.name)
+
def on_update(self):
self.check_recursion()
self.reschedule_dependent_tasks()