Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: timeout error for work order (backport #45177) #45179

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions erpnext/manufacturing/doctype/job_card/job_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ def has_overlap(self, production_capacity, time_logs):
return overlap

def get_time_logs(self, args, doctype, open_job_cards=None):
if get_datetime(args.from_time) >= get_datetime(args.to_time):
args.to_time = add_to_date(args.from_time, minutes=args.remaining_time_in_mins)

jc = frappe.qb.DocType("Job Card")
jctl = frappe.qb.DocType(doctype)

Expand Down Expand Up @@ -354,8 +357,10 @@ def get_time_logs(self, args, doctype, open_job_cards=None):
else:
query = query.where(jc.name.isin(open_job_cards))

if doctype != "Job Card Time Log":
query = query.where(jc.total_time_in_mins == 0)
if doctype == "Job Card Time Log":
query = query.where(jc.docstatus < 2)
else:
query = query.where((jc.docstatus == 0) & (jc.total_time_in_mins == 0))

time_logs = query.run(as_dict=True)

Expand Down Expand Up @@ -412,7 +417,13 @@ def time_slot_wise_busy_workstations(existing_time_logs) -> dict:
def schedule_time_logs(self, row):
row.remaining_time_in_mins = row.time_in_mins
while row.remaining_time_in_mins > 0:
args = frappe._dict({"from_time": row.planned_start_time, "to_time": row.planned_end_time})
args = frappe._dict(
{
"from_time": row.planned_start_time,
"to_time": row.planned_end_time,
"remaining_time_in_mins": row.remaining_time_in_mins,
}
)

self.validate_overlap_for_workstation(args, row)
self.check_workstation_time(row)
Expand Down
Loading