diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 797f8869b0..2136df3e31 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -5,7 +5,7 @@ import frappe from erpnext.hooks import regional_overrides from frappe.utils import getdate -__version__ = '10.1.47' +__version__ = '10.1.48' def get_default_company(user=None): '''Get default company for user''' diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py index b1a11398c2..09726dac28 100644 --- a/erpnext/projects/doctype/project/project.py +++ b/erpnext/projects/doctype/project/project.py @@ -52,7 +52,14 @@ class Project(Document): if self.name is None: return {} else: - return frappe.get_all("Task", "*", {"project": self.name}, order_by="exp_start_date asc") + filters = {"project": self.name} + + if self.get("deleted_task_list"): + filters.update({ + 'name': ("not in", self.deleted_task_list) + }) + + return frappe.get_all("Task", "*", filters, order_by="exp_start_date asc") def validate(self): self.validate_project_name() @@ -60,6 +67,7 @@ class Project(Document): self.validate_weights() self.sync_tasks() self.tasks = [] + self.load_tasks() self.send_welcome_email() def validate_project_name(self): @@ -88,8 +96,19 @@ class Project(Document): task_names = [] existing_task_data = {} + + fields = ["title", "status", "start_date", "end_date", "description", "task_weight", "task_id"] + exclude_fieldtype = ["Button", "Column Break", + "Section Break", "Table", "Read Only", "Attach", "Attach Image", "Color", "Geolocation", "HTML", "Image"] + + custom_fields = frappe.get_all("Custom Field", {"dt": "Project Task", + "fieldtype": ("not in", exclude_fieldtype)}, "fieldname") + + for d in custom_fields: + fields.append(d.fieldname) + for d in frappe.get_all('Project Task', - fields = ["title", "status", "start_date", "end_date", "description", "task_weight", "task_id"], + fields = fields, filters = {'parent': self.name}): existing_task_data.setdefault(d.task_id, d) @@ -100,7 +119,7 @@ class Project(Document): task = frappe.new_doc("Task") task.project = self.name - if not t.task_id or self.is_row_updated(t, existing_task_data): + if not t.task_id or self.is_row_updated(t, existing_task_data, fields): task.update({ "subject": t.title, "status": t.status, @@ -138,22 +157,15 @@ class Project(Document): self.update_percent_complete() self.update_costing() - def is_row_updated(self, row, existing_task_data): + def is_row_updated(self, row, existing_task_data, fields): 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) - for field in project_task_custom_fields: + for field in fields: if row.get(field) != d.get(field): return True - 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 row.description != d.description or row.task_weight != d.task_weight)): - return True - def map_custom_fields(self, source, target): project_task_custom_fields = frappe.get_all("Custom Field", {"dt": "Project Task"}, "fieldname")