Merge pull request #3625 from neilLasrado/task
Validation added to prevent task being closed with open dependent tasks
This commit is contained in:
commit
b4ec294463
@ -28,10 +28,7 @@ class Task(Document):
|
|||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_dates()
|
self.validate_dates()
|
||||||
|
self.validate_status()
|
||||||
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)
|
|
||||||
|
|
||||||
def validate_dates(self):
|
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):
|
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 @@ class Task(Document):
|
|||||||
if self.act_start_date and self.act_end_date and getdate(self.act_start_date) > getdate(self.act_end_date):
|
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'"))
|
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):
|
def on_update(self):
|
||||||
self.check_recursion()
|
self.check_recursion()
|
||||||
self.reschedule_dependent_tasks()
|
self.reschedule_dependent_tasks()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user