mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 03:39:11 +00:00
fix: get_doc to avoid modified error
This commit is contained in:
@@ -81,12 +81,12 @@ class Project(Document):
|
|||||||
def dependency_mapping(self, template_tasks, project_tasks):
|
def dependency_mapping(self, template_tasks, project_tasks):
|
||||||
for template_task in template_tasks:
|
for template_task in template_tasks:
|
||||||
project_task = list(filter(lambda x: x.subject == template_task.subject, project_tasks))[0]
|
project_task = list(filter(lambda x: x.subject == template_task.subject, project_tasks))[0]
|
||||||
if template_task.get("depends_on") and not project_task.get("depends_on"):
|
project_task = frappe.get_doc("Task", project_task.name)
|
||||||
self.check_depends_on_value(template_task, project_task, project_tasks)
|
self.check_depends_on_value(template_task, project_task, project_tasks)
|
||||||
if template_task.get("parent_task") and not project_task.get("parent_task"):
|
|
||||||
self.check_for_parent_tasks(template_task, project_task, project_tasks)
|
self.check_for_parent_tasks(template_task, project_task, project_tasks)
|
||||||
|
|
||||||
def check_depends_on_value(self, template_task, project_task, project_tasks):
|
def check_depends_on_value(self, template_task, project_task, project_tasks):
|
||||||
|
if template_task.get("depends_on") and not project_task.get("depends_on"):
|
||||||
for child_task in template_task.get("depends_on"):
|
for child_task in template_task.get("depends_on"):
|
||||||
child_task_subject = frappe.db.get_value("Task", child_task.task, "subject")
|
child_task_subject = frappe.db.get_value("Task", child_task.task, "subject")
|
||||||
corresponding_project_task = list(filter(lambda x: x.subject == child_task_subject, project_tasks))
|
corresponding_project_task = list(filter(lambda x: x.subject == child_task_subject, project_tasks))
|
||||||
@@ -97,6 +97,7 @@ class Project(Document):
|
|||||||
project_task.save()
|
project_task.save()
|
||||||
|
|
||||||
def check_for_parent_tasks(self, template_task, project_task, project_tasks):
|
def check_for_parent_tasks(self, template_task, project_task, project_tasks):
|
||||||
|
if template_task.get("parent_task") and not project_task.get("parent_task"):
|
||||||
parent_task_subject = frappe.db.get_value("Task", template_task.get("parent_task"), "subject")
|
parent_task_subject = frappe.db.get_value("Task", template_task.get("parent_task"), "subject")
|
||||||
corresponding_project_task = list(filter(lambda x: x.subject == parent_task_subject, project_tasks))
|
corresponding_project_task = list(filter(lambda x: x.subject == parent_task_subject, project_tasks))
|
||||||
if len(corresponding_project_task):
|
if len(corresponding_project_task):
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class TestProject(unittest.TestCase):
|
|||||||
|
|
||||||
template = make_project_template("Test Project Template - Tasks with Parent-Child Relation", [task1, task2, task3])
|
template = make_project_template("Test Project Template - Tasks with Parent-Child Relation", [task1, task2, task3])
|
||||||
project = get_project(project_name, template)
|
project = get_project(project_name, template)
|
||||||
tasks = frappe.get_all('Task', ['subject','exp_end_date','depends_on_tasks', 'name'], dict(project=project.name), order_by='creation asc')
|
tasks = frappe.get_all('Task', ['subject','exp_end_date','depends_on_tasks', 'name', 'parent_task'], dict(project=project.name), order_by='creation asc')
|
||||||
|
|
||||||
self.assertEqual(tasks[0].subject, 'Test Template Task Parent')
|
self.assertEqual(tasks[0].subject, 'Test Template Task Parent')
|
||||||
self.assertEqual(getdate(tasks[0].exp_end_date), calculate_end_date(project, 1, 1))
|
self.assertEqual(getdate(tasks[0].exp_end_date), calculate_end_date(project, 1, 1))
|
||||||
|
|||||||
Reference in New Issue
Block a user