From cab73b8a02c8835e34b0f85c7afdbdac1c50936f Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 9 Feb 2018 16:30:18 +0530 Subject: [PATCH] [fix] execute update_time_and_costing and update_project only for distinct task and projects --- erpnext/projects/doctype/timesheet/timesheet.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index 8d339b9ce6..3d94b5ce00 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -156,14 +156,18 @@ class Timesheet(Document): (self.production_order, operation_id), as_dict=1)[0] def update_task_and_project(self): + tasks, projects = [], [] + for data in self.time_logs: - if data.task: + if data.task and data.task not in tasks: task = frappe.get_doc("Task", data.task) task.update_time_and_costing() task.save() + tasks.append(data.task) - elif data.project: + elif data.project and data.project not in projects: frappe.get_doc("Project", data.project).update_project() + projects.append(data.project) def validate_dates(self): for data in self.time_logs: