Thank you!
I actually went with what peterg recommended,
So for anyone that might need this,
Incases where you have multiple dependent tasks like this, and one task opens the other
The following list view might be overwhelming specially when only Child Task 1 can be worked on
So we can filter it to look like this,
Once a task is completed, the following task will automatically open.
To do this,
- Start by customizing the Task Doctype
Create a new Select Field
Name: actual_task_status
Options: Open, Closed
Enable Read Only
- Create a Client Script – Apply to Tasks Form
frappe.ui.form.on('Task Depends On', {
task(frm) {
if(frm.doc.depends_on)
frm.set_value('actual_task_status','Closed')
else
frm.set_value('actual_task_status','Open')
return True
}
});
frappe.ui.form.on('Task', {
is_group(frm) {
if(frm.doc.is_group)
frm.set_value('actual_task_status','Closed')
else
frm.set_value('actual_task_status','Open')
}
});
frappe.ui.form.on('Task', {
status(frm) {
if(frm.doc.status=='Completed' || frm.doc.status=='Template' || frm.doc.status=='Cancelled' )
frm.set_value('actual_task_status','Closed')
else
frm.set_value('actual_task_status','Open')
}
});
- Create a Before_Save Server Script on Task
if doc.name and doc.status=='Template':
doc.actual_task_status='Closed'
if doc.name and doc.status=='Cancelled':
doc.actual_task_status='Closed'
if doc.name and doc.status=='Completed':
doc.actual_task_status='Closed'
tasks = frappe.get_list('Task Depends On',filters={'task':doc.name},fields=['task','parent'])
for task in tasks:
if task.parent!=doc.parent_task:
depend_tasks = frappe.get_list('Task Depends On',filters={'parent':task.parent},fields=['task','parent'])
check = True
for dt in depend_tasks:
if dt.task!=task.task and frappe.db.get_value('Task',{'name',dt.task},'status')!='Completed':
check=False
break
if check:
dd=frappe.get_doc('Task',task.parent)
dd.actual_task_status='Open'
dd.save()
del dd
if doc.parent_task:
depend_tasks = frappe.get_list('Task Depends On',filters=dict({ 'parent':doc.parent_task }),fields=['task','parent'])
check = True
for dt in depend_tasks:
if dt.task!=task.task and frappe.db.get_value('Task',dt.task,'status')!='Completed':
check=False
break
if check:
dd=frappe.get_doc('Task',doc.parent_task)
dd.actual_task_status='Open'
dd.save()
del dd
elif doc.get("__islocal") and (doc.depends_on or doc.depends_on_tasks or doc.is_group or doc.status=='Completed' or doc.status=='Template' or doc.status=='Cancelled'):
doc.actual_task_status='Closed'
- Create a After_Save Server Script on Task
if doc.name and doc.status=='Open':
depend_tasks = frappe.get_list('Task Depends On',filters={'parent':doc.name},fields=['task','parent'])
if depend_tasks:
doc.actual_task_status='Closed'
Tested on both manual task creation and tasks made via project template.
For custom workflows, make sure the end state changes the “status” field to “completed”