Merge pull request #17464 from Mangesh-Khairnar/task-unlink
feat: unlink task from project on task deletion
diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py
index ac71b28..84ee715 100755
--- a/erpnext/projects/doctype/task/task.py
+++ b/erpnext/projects/doctype/task/task.py
@@ -163,6 +163,13 @@
if check_if_child_exists(self.name):
throw(_("Child Task exists for this Task. You can not delete this Task."))
+ if self.project:
+ tasks = frappe.get_doc('Project', self.project).tasks
+ for task in tasks:
+ if task.get('task_id') == self.name:
+ frappe.delete_doc('Project Task', task.name)
+
+
self.update_nsm_model()
def update_status(self):