From 704913989a6f2df8feefc90f1444c298f520f69b Mon Sep 17 00:00:00 2001 From: Anoop Kurungadam Date: Tue, 3 Dec 2024 15:29:26 +0530 Subject: [PATCH] fix: initialize task_end_time before calculating task_duration (cherry picked from commit 6660ffa642686a4e1756aba6288b2c894368c36a) --- .../healthcare/doctype/nursing_task/nursing_task.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/healthcare/healthcare/doctype/nursing_task/nursing_task.py b/healthcare/healthcare/doctype/nursing_task/nursing_task.py index 7734eda549..38001b10f0 100644 --- a/healthcare/healthcare/doctype/nursing_task/nursing_task.py +++ b/healthcare/healthcare/doctype/nursing_task/nursing_task.py @@ -14,16 +14,12 @@ class NursingTask(Document): def before_insert(self): - # set requested start / end self.set_task_schedule() - self.title = "{} - {}".format(_(self.patient), _(self.activity)) - self.age = frappe.get_doc("Patient", self.patient).get_age() def validate(self): if self.status == "Requested": - # auto submit if status is Requested self.docstatus = 1 def on_submit(self): @@ -47,10 +43,11 @@ def on_update_after_submit(self): self.db_set("task_start_time", now_datetime()) elif self.status == "Completed": + task_end_time = now_datetime() self.db_set( { - "task_end_time": now_datetime(), - "task_duration": time_diff_in_seconds(self.task_end_time, self.task_start_time), + "task_end_time": task_end_time, + "task_duration": time_diff_in_seconds(task_end_time, self.task_start_time), } )