fix: Set todo status as Closed if task completed (#19059)
diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py
index c98b64d..90e9f05 100755
--- a/erpnext/projects/doctype/task/task.py
+++ b/erpnext/projects/doctype/task/task.py
@@ -9,7 +9,7 @@
from frappe import _, throw
from frappe.utils import add_days, cstr, date_diff, get_link_to_form, getdate
from frappe.utils.nestedset import NestedSet
-
+from frappe.desk.form.assign_to import close_all_assignments, clear
class CircularReferenceError(frappe.ValidationError): pass
class EndDateCannotBeGreaterThanProjectEndDateError(frappe.ValidationError): pass
@@ -45,8 +45,7 @@
if frappe.db.get_value("Task", d.task, "status") != "Completed":
frappe.throw(_("Cannot close task {0} as its dependant task {1} is not closed.").format(frappe.bold(self.name), frappe.bold(d.task)))
- from frappe.desk.form.assign_to import clear
- clear(self.doctype, self.name)
+ close_all_assignments(self.doctype, self.name)
def validate_progress(self):
if (self.progress or 0) > 100:
@@ -77,8 +76,9 @@
self.populate_depends_on()
def unassign_todo(self):
- if self.status in ("Completed", "Cancelled"):
- from frappe.desk.form.assign_to import clear
+ if self.status == "Completed":
+ close_all_assignments(self.doctype, self.name)
+ if self.status == "Cancelled":
clear(self.doctype, self.name)
def update_total_expense_claim(self):