Load tasks in project for printing purpose

This commit is contained in:
Nabin Hait 2015-06-12 17:37:28 +05:30
parent 804b4acb9b
commit 89592c5180

View File

@ -13,19 +13,25 @@ class Project(Document):
def get_feed(self): def get_feed(self):
return '{0}: {1}'.format(_(self.status), self.project_name) return '{0}: {1}'.format(_(self.status), self.project_name)
def __setup__(self): def onload(self):
"""Load project tasks for quick view""" """Load project tasks for quick view"""
self.tasks = [] if not self.get("tasks"):
for task in frappe.get_all("Task", "*", {"project": self.name}, order_by="exp_start_date asc"): for task in self.get_tasks():
self.append("tasks", { self.append("tasks", {
"title": task.subject, "title": task.subject,
"status": task.status, "status": task.status,
"start_date": task.exp_start_date, "start_date": task.exp_start_date,
"end_date": task.exp_end_date, "end_date": task.exp_end_date,
"description": task.description, "description": task.description,
"task_id": task.name "task_id": task.name
}) })
def __setup__(self):
self.onload()
def get_tasks(self):
return frappe.get_all("Task", "*", {"project": self.name}, order_by="exp_start_date asc")
def validate(self): def validate(self):
self.validate_dates() self.validate_dates()
self.sync_tasks() self.sync_tasks()