fix: not able to complete job card

(cherry picked from commit 175fe9279c)
This commit is contained in:
Rohit Waghchaure
2026-02-04 16:55:36 +05:30
committed by Mergify
parent 1dc44691db
commit c5ff534d58

View File

@@ -1251,10 +1251,26 @@ class JobCard(Document):
frappe.db.set_value("Workstation", self.workstation, "status", status) frappe.db.set_value("Workstation", self.workstation, "status", status)
def add_time_logs(self, **kwargs): def add_time_logs(self, **kwargs):
row = None
kwargs = frappe._dict(kwargs) kwargs = frappe._dict(kwargs)
if not kwargs.employees and kwargs.to_time:
for row in self.time_logs:
if not row.to_time and row.from_time:
row.to_time = kwargs.to_time
row.time_in_mins = time_diff_in_minutes(row.to_time, row.from_time)
if kwargs.completed_qty:
row.completed_qty = kwargs.completed_qty
row.db_update()
else:
self.add_time_logs_for_employess(kwargs)
self.validate_time_logs(save=True)
self.save()
def add_time_logs_for_employess(self, kwargs):
row = None
update_status = False update_status = False
for employee in kwargs.employees: for employee in kwargs.employees:
kwargs.employee = employee.get("employee") kwargs.employee = employee.get("employee")
if kwargs.from_time and not kwargs.to_time: if kwargs.from_time and not kwargs.to_time:
@@ -1290,9 +1306,6 @@ class JobCard(Document):
self.set_status(update_status=update_status) self.set_status(update_status=update_status)
self.validate_time_logs(save=True)
self.save()
def update_workstation_status(self): def update_workstation_status(self):
status_map = { status_map = {
"Open": "Off", "Open": "Off",