[Fix] Not able to delete the task even if task removed from the project (#15105)
* [Fix] Not able to delete the task even if task removed from the project * [Fix] Custom field's data in task not updating from the project
This commit is contained in:
parent
59de1dae6a
commit
ba62013cbb
@ -60,7 +60,6 @@ class Project(Document):
|
|||||||
self.validate_weights()
|
self.validate_weights()
|
||||||
self.sync_tasks()
|
self.sync_tasks()
|
||||||
self.tasks = []
|
self.tasks = []
|
||||||
self.load_tasks()
|
|
||||||
self.send_welcome_email()
|
self.send_welcome_email()
|
||||||
|
|
||||||
def validate_project_name(self):
|
def validate_project_name(self):
|
||||||
@ -82,6 +81,9 @@ class Project(Document):
|
|||||||
|
|
||||||
def sync_tasks(self):
|
def sync_tasks(self):
|
||||||
"""sync tasks and remove table"""
|
"""sync tasks and remove table"""
|
||||||
|
if not hasattr(self, "deleted_task_list"):
|
||||||
|
self.set("deleted_task_list", [])
|
||||||
|
|
||||||
if self.flags.dont_sync_tasks: return
|
if self.flags.dont_sync_tasks: return
|
||||||
task_names = []
|
task_names = []
|
||||||
|
|
||||||
@ -130,7 +132,7 @@ class Project(Document):
|
|||||||
|
|
||||||
# delete
|
# delete
|
||||||
for t in frappe.get_all("Task", ["name"], {"project": self.name, "name": ("not in", task_names)}):
|
for t in frappe.get_all("Task", ["name"], {"project": self.name, "name": ("not in", task_names)}):
|
||||||
frappe.delete_doc("Task", t.name)
|
self.deleted_task_list.append(t.name)
|
||||||
|
|
||||||
def update_costing_and_percentage_complete(self):
|
def update_costing_and_percentage_complete(self):
|
||||||
self.update_percent_complete()
|
self.update_percent_complete()
|
||||||
@ -139,8 +141,14 @@ class Project(Document):
|
|||||||
def is_row_updated(self, row, existing_task_data):
|
def is_row_updated(self, row, existing_task_data):
|
||||||
if self.get("__islocal") or not existing_task_data: return True
|
if self.get("__islocal") or not existing_task_data: return True
|
||||||
|
|
||||||
|
project_task_custom_fields = frappe.get_all("Custom Field", {"dt": "Project Task"}, "fieldname")
|
||||||
|
|
||||||
d = existing_task_data.get(row.task_id)
|
d = existing_task_data.get(row.task_id)
|
||||||
|
|
||||||
|
for field in project_task_custom_fields:
|
||||||
|
if row.get(field) != d.get(field):
|
||||||
|
return True
|
||||||
|
|
||||||
if (d and (row.title != d.title or row.status != d.status
|
if (d and (row.title != d.title or row.status != d.status
|
||||||
or getdate(row.start_date) != getdate(d.start_date) or getdate(row.end_date) != getdate(d.end_date)
|
or getdate(row.start_date) != getdate(d.start_date) or getdate(row.end_date) != getdate(d.end_date)
|
||||||
or row.description != d.description or row.task_weight != d.task_weight)):
|
or row.description != d.description or row.task_weight != d.task_weight)):
|
||||||
@ -263,9 +271,19 @@ class Project(Document):
|
|||||||
user.welcome_email_sent=1
|
user.welcome_email_sent=1
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
|
self.delete_task()
|
||||||
|
self.load_tasks()
|
||||||
self.update_costing_and_percentage_complete()
|
self.update_costing_and_percentage_complete()
|
||||||
self.update_dependencies_on_duplicated_project()
|
self.update_dependencies_on_duplicated_project()
|
||||||
|
|
||||||
|
def delete_task(self):
|
||||||
|
if not self.get('deleted_task_list'): return
|
||||||
|
|
||||||
|
for d in self.get('deleted_task_list'):
|
||||||
|
frappe.delete_doc("Task", d)
|
||||||
|
|
||||||
|
self.deleted_task_list = []
|
||||||
|
|
||||||
def update_dependencies_on_duplicated_project(self):
|
def update_dependencies_on_duplicated_project(self):
|
||||||
if self.flags.dont_sync_tasks: return
|
if self.flags.dont_sync_tasks: return
|
||||||
if not self.copied_from:
|
if not self.copied_from:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user