feat: Added check for no end date and refactored query

This commit is contained in:
scmmishra 2019-03-24 20:43:15 +05:30
parent 6ab6d35f92
commit f7f32634c8

View File

@ -160,7 +160,7 @@ class Task(NestedSet):
self.update_nsm_model()
def update_status(self):
if self.status not in ('Cancelled', 'Closed'):
if self.status not in ('Cancelled', 'Closed') and self.exp_end_date:
from datetime import datetime
if self.exp_end_date < datetime.now().date():
self.date = 'Overdue'
@ -193,7 +193,7 @@ def set_multiple_status(names, status):
task.save()
def set_tasks_as_overdue():
tasks = frappe.get_all("Task")
tasks = frappe.get_all("Task", filters={'status':['not in',['Cancelled', 'Closed']]})
for task in tasks:
frappe.get_doc("Task", task.name).update_status()