fix: job card timer issue (backport #56405) (#56406)

fix: job card timer issue (#56405)

(cherry picked from commit 21541e3ad3)

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
mergify[bot]
2026-06-24 09:21:02 +05:30
committed by GitHub
parent d54938fa64
commit 54c45d7b22

View File

@@ -694,10 +694,11 @@ frappe.ui.form.on("Job Card", {
// ── Wire up button click handlers ───────────────────────────────── // ── Wire up button click handlers ─────────────────────────────────
if (show_start) { if (show_start) {
wrapper.find(".jcd-btn-start").on("click", () => { wrapper.find(".jcd-btn-start").on("click", () => {
const from_time = frappe.datetime.now_datetime();
const has_no_employee = !frm.doc.employee || !frm.doc.employee.length; const has_no_employee = !frm.doc.employee || !frm.doc.employee.length;
if (has_no_employee) { if (has_no_employee) {
// Capture the start time only when the employee dialog is submitted, not on click,
// so the time spent selecting the operator is not counted as worked time.
frappe.prompt( frappe.prompt(
{ {
fieldtype: "Table MultiSelect", fieldtype: "Table MultiSelect",
@@ -707,11 +708,11 @@ frappe.ui.form.on("Job Card", {
reqd: 1, reqd: 1,
filters: { status: "Active" }, filters: { status: "Active" },
}, },
(d) => frm.events.start_timer(frm, from_time, d.employees), (d) => frm.events.start_timer(frm, frappe.datetime.now_datetime(), d.employees),
__("Assign Job to Employee") __("Assign Job to Employee")
); );
} else { } else {
frm.events.start_timer(frm, from_time, frm.doc.employee); frm.events.start_timer(frm, frappe.datetime.now_datetime(), frm.doc.employee);
} }
}); });
} }