From 6ef8b41c3ceaab00d846843f94f82af2e53b7675 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 22 Jun 2026 18:25:17 +0530 Subject: [PATCH] test(project-template): cover dependency-task validation A template task that depends on another task requires that dependency to also be present in the template's task list; covers both the rejection and the valid case. --- .../project_template/test_project_template.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/erpnext/projects/doctype/project_template/test_project_template.py b/erpnext/projects/doctype/project_template/test_project_template.py index 7677abd1890..d13b12400fe 100644 --- a/erpnext/projects/doctype/project_template/test_project_template.py +++ b/erpnext/projects/doctype/project_template/test_project_template.py @@ -8,7 +8,19 @@ from erpnext.tests.utils import ERPNextTestSuite class TestProjectTemplate(ERPNextTestSuite): - pass + def test_dependency_task_must_be_in_template(self): + dependency = create_task("_Test PT Dependency", is_template=1) + dependent = create_task("_Test PT Dependent", is_template=1, depends_on=dependency.name) + + template = frappe.get_doc(doctype="Project Template", name="_Test PT Missing Dependency") + template.append("tasks", {"task": dependent.name}) + # the dependency task is not in the template's task list + self.assertRaises(frappe.ValidationError, template.insert) + + # adding the dependency task makes the template valid + template.append("tasks", {"task": dependency.name}) + template.insert() + self.assertTrue(frappe.db.exists("Project Template", template.name)) def make_project_template(project_template_name, project_tasks=None):