Skip to content

Commit

Permalink
fix: Must not be able to start Job Card if it is related to Work Orde…
Browse files Browse the repository at this point in the history
…r 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 143786a)

Co-authored-by: HENRY Florian <florian.henry@open-concept.pro>
  • Loading branch information
mergify[bot] and FHenry authored Apr 20, 2022
1 parent 0b4e3f1 commit b656ffa
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion erpnext/manufacturing/doctype/job_card/job_card.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit b656ffa

Please sign in to comment.