diff --git a/erpnext/manufacturing/doctype/job_card/job_card.js b/erpnext/manufacturing/doctype/job_card/job_card.js index b6646b19f6..619e6bd1a0 100644 --- a/erpnext/manufacturing/doctype/job_card/job_card.js +++ b/erpnext/manufacturing/doctype/job_card/job_card.js @@ -33,6 +33,11 @@ frappe.ui.form.on('Job Card', { return; } + let has_stock_entry = frm.doc.__onload && + frm.doc.__onload.has_stock_entry ? true : false; + + frm.toggle_enable("for_quantity", !has_stock_entry); + if (!frm.is_new() && has_items && frm.doc.docstatus < 2) { let to_request = frm.doc.for_quantity > frm.doc.transferred_qty; let excess_transfer_allowed = frm.doc.__onload.job_card_excess_transfer; diff --git a/erpnext/manufacturing/doctype/job_card/job_card.py b/erpnext/manufacturing/doctype/job_card/job_card.py index 822647526f..3133628cbf 100644 --- a/erpnext/manufacturing/doctype/job_card/job_card.py +++ b/erpnext/manufacturing/doctype/job_card/job_card.py @@ -57,6 +57,10 @@ class JobCard(Document): ) self.set_onload("job_card_excess_transfer", excess_transfer) self.set_onload("work_order_closed", self.is_work_order_closed()) + self.set_onload("has_stock_entry", self.has_stock_entry()) + + def has_stock_entry(self): + return frappe.db.exists("Stock Entry", {"job_card": self.name, "docstatus": ["!=", 2]}) def before_validate(self): self.set_wip_warehouse()