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()
|
||||
|
||||
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()
|
||||
def check_if_child_exists(name):
|
||||
child_tasks = frappe.get_all("Task", filters={"parent_task": name})
|
||||
@ -186,10 +193,9 @@ def set_multiple_status(names, status):
|
||||
task.save()
|
||||
|
||||
def set_tasks_as_overdue():
|
||||
frappe.db.sql("""update tabTask set `status`='Overdue'
|
||||
where exp_end_date is not null
|
||||
and exp_end_date < CURDATE()
|
||||
and `status` not in ('Closed', 'Cancelled')""")
|
||||
tasks = frappe.get_all("Task")
|
||||
for task in tasks:
|
||||
frappe.get_doc("Task", task.name).update_status()
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_children(doctype, parent, task=None, project=None, is_root=False):
|
||||
|
Loading…
x
Reference in New Issue
Block a user