depends-on added to task, circular reference validation added

This commit is contained in:
Neil Trini Lasrado 2015-04-22 16:28:30 +05:30
parent 0e1540b3b7
commit 93583faaf0
2 changed files with 25 additions and 1 deletions

View File

@ -27,6 +27,14 @@
"options": "Project",
"permlevel": 0
},
{
"fieldname": "depends_on",
"fieldtype": "Link",
"label": "Depends on (Task)",
"options": "Task",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "column_break0",
"fieldtype": "Column Break",
@ -249,7 +257,7 @@
"idx": 1,
"istable": 0,
"max_attachments": 5,
"modified": "2015-04-14 07:56:24.481667",
"modified": "2015-04-22 04:58:30.865304",
"modified_by": "Administrator",
"module": "Projects",
"name": "Task",

View File

@ -27,6 +27,7 @@ class Task(Document):
def validate(self):
self.validate_dates()
self.validate_depends_on()
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):
@ -68,6 +69,21 @@ class Task(Document):
project.flags.dont_sync_tasks = True
project.update_costing()
project.save()
def validate_depends_on(self):
if not self.depends_on:
return
task_list = [self.name]
task = self.depends_on
while task:
task = self.check_recursion(task, task_list)
def check_recursion(self, task, task_list):
if task in task_list:
frappe.throw("Circular Reference Error")
else :
task_list.append(task)
return frappe.db.get_value("Task", task, "depends_on")
@frappe.whitelist()
def get_events(start, end, filters=None):