fix: only set times if job card is filled (#19107)
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.py b/erpnext/manufacturing/doctype/job_card/job_card.py
index a8faa13..9d2e620 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.py
+++ b/erpnext/manufacturing/doctype/job_card/job_card.py
@@ -105,7 +105,6 @@
for_quantity, time_in_mins = 0, 0
from_time_list, to_time_list = [], []
-
for d in frappe.get_all('Job Card',
filters = {'docstatus': 1, 'operation_id': self.operation_id}):
doc = frappe.get_doc('Job Card', d.name)
@@ -125,8 +124,8 @@
if data.name == self.operation_id:
data.completed_qty = for_quantity
data.actual_operation_time = time_in_mins
- data.actual_start_time = min(from_time_list)
- data.actual_end_time = max(to_time_list)
+ data.actual_start_time = min(from_time_list) if from_time_list else None
+ data.actual_end_time = max(to_time_list) if to_time_list else None
wo.flags.ignore_validate_update_after_submit = True
wo.update_operation_status()