fix: Task Overdue status propagates to project
- Used ORM instead of a SQL for set_task_as_overdue - update_status function compares the time and marks the appropriate task as overdue - The on_update hook makes the changes in project as well
This commit is contained in:
parent
9673d0ddae
commit
6ab6d35f92
@ -159,6 +159,13 @@ class Task(NestedSet):
|
|||||||
|
|
||||||
self.update_nsm_model()
|
self.update_nsm_model()
|
||||||
|
|
||||||
|
def update_status(self):
|
||||||
|
if self.status not in ('Cancelled', 'Closed'):
|
||||||
|
from datetime import datetime
|
||||||
|
if self.exp_end_date < datetime.now().date():
|
||||||
|
self.date = 'Overdue'
|
||||||
|
self.save()
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def check_if_child_exists(name):
|
def check_if_child_exists(name):
|
||||||
child_tasks = frappe.get_all("Task", filters={"parent_task": name})
|
child_tasks = frappe.get_all("Task", filters={"parent_task": name})
|
||||||
@ -186,10 +193,9 @@ def set_multiple_status(names, status):
|
|||||||
task.save()
|
task.save()
|
||||||
|
|
||||||
def set_tasks_as_overdue():
|
def set_tasks_as_overdue():
|
||||||
frappe.db.sql("""update tabTask set `status`='Overdue'
|
tasks = frappe.get_all("Task")
|
||||||
where exp_end_date is not null
|
for task in tasks:
|
||||||
and exp_end_date < CURDATE()
|
frappe.get_doc("Task", task.name).update_status()
|
||||||
and `status` not in ('Closed', 'Cancelled')""")
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_children(doctype, parent, task=None, project=None, is_root=False):
|
def get_children(doctype, parent, task=None, project=None, is_root=False):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user