fix: Must not be able to start Job Card if it is related to Work Order that is not started yet (#29072) (#30755)

* fix: Cannot start Job strat if related to Work Order not started yet

* fix: Cannot start Job strat if related to Work Order not started yet

* test

* test

* fix siders

* PR review

* chore: Code cleanup

- Better short circuit for if condition (make it such that both conditions dont always have to be computed)
- Remove `r.message` extraction by avoiding `then()`

* chore: Remove unnecessary json change

Co-authored-by: marination <maricadsouza221197@gmail.com>
(cherry picked from commit 143786aaa0)

Co-authored-by: HENRY Florian <florian.henry@open-concept.pro>
This commit is contained in:
mergify[bot]
2022-04-20 15:11:11 +05:30
committed by GitHub
parent 0b4e3f1467
commit b656ffa45e

View File

@@ -73,7 +73,18 @@ frappe.ui.form.on('Job Card', {
if (frm.doc.docstatus == 0 && !frm.is_new() &&
(frm.doc.for_quantity > frm.doc.total_completed_qty || !frm.doc.for_quantity)
&& (frm.doc.items || !frm.doc.items.length || frm.doc.for_quantity == frm.doc.transferred_qty)) {
frm.trigger("prepare_timer_buttons");
// if Job Card is link to Work Order, the job card must not be able to start if Work Order not "Started"
// and if stock mvt for WIP is required
if (frm.doc.work_order) {
frappe.db.get_value('Work Order', frm.doc.work_order, ['skip_transfer', 'status'], (result) => {
if (result.skip_transfer === 1 || result.status == 'In Process') {
frm.trigger("prepare_timer_buttons");
}
});
} else {
frm.trigger("prepare_timer_buttons");
}
}
frm.trigger("setup_quality_inspection");