Hello,
Can anybody answer this? Its very urgent to me…
How the rows are get inserted in to ‘Task" table instead of "Project task’ in ‘Project’ doctype?
1 Like
@Amalendu
Project Task is not stored in Project Task table. Project Task only saved in Task table.
When one load Project, All task is fetched related to that project using get_task() and appended to project_task child table.
from email_reply_parser import EmailReplyParser
from frappe import _
from frappe.desk.reportview import get_match_cond
from frappe.model.document import Document
from frappe.utils import add_days, flt, get_datetime, get_time, get_url, nowtime, today
from erpnext import get_default_company
from erpnext.controllers.queries import get_filters_cond
from erpnext.setup.doctype.holiday_list.holiday_list import is_holiday
class Project(Document):
def onload(self):
self.set_onload(
"activity_summary",
frappe.db.sql(
"""select activity_type,
sum(hours) as total_hours
from `tabTimesheet Detail` where project=%s and docstatus < 2 group by activity_type
order by total_hours desc""",
self.name,
When you save project, sync_task() is used to update or create task.
self.update_costing()
self.update_percent_complete()
self.validate_from_to_dates("expected_start_date", "expected_end_date")
self.validate_from_to_dates("actual_start_date", "actual_end_date")
def copy_from_template(self):
"""
Copy tasks from template
"""
if self.project_template and not frappe.db.get_all("Task", dict(project=self.name), limit=1):
# has a template, and no loaded tasks, so lets create
if not self.expected_start_date:
# project starts today
self.expected_start_date = today()
template = frappe.get_doc("Project Template", self.project_template)
if not self.project_type:
self.project_type = template.project_type
& here is important thing, after sync and before save, all project task is cleared, so task will never stored into project_task child table
def before_print(self, settings=None):
self.onload()
def validate(self):
if not self.is_new():
self.copy_from_template()
self.send_welcome_email()
self.update_costing()
self.update_percent_complete()
self.validate_from_to_dates("expected_start_date", "expected_end_date")
self.validate_from_to_dates("actual_start_date", "actual_end_date")
def copy_from_template(self):
"""
Copy tasks from template
"""
if self.project_template and not frappe.db.get_all("Task", dict(project=self.name), limit=1):
# has a template, and no loaded tasks, so lets create
if not self.expected_start_date:
2 Likes
@kolate_sambhaji Thank You so much…
Understood the flow…
1 Like