diff --git a/erpnext/manufacturing/doctype/work_order/work_order.js b/erpnext/manufacturing/doctype/work_order/work_order.js index 96e44c881b..1789a1f883 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.js +++ b/erpnext/manufacturing/doctype/work_order/work_order.js @@ -91,6 +91,16 @@ frappe.ui.form.on("Work Order", { }; }); + frm.set_query("operation", "required_items", function() { + return { + query: "erpnext.manufacturing.doctype.work_order.work_order.get_bom_operations", + filters: { + 'parent': frm.doc.bom_no, + 'parenttype': 'BOM' + } + }; + }); + // formatter for work order operation frm.set_indicator_formatter('operation', function(doc) { return (frm.doc.qty==doc.completed_qty) ? "green" : "orange"; }); diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py index 24b798b04c..678e709416 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.py +++ b/erpnext/manufacturing/doctype/work_order/work_order.py @@ -543,6 +543,13 @@ class WorkOrder(Document): bom.set_bom_material_details() return bom +def get_bom_operations(doctype, txt, searchfield, start, page_len, filters): + if txt: + filters['operation'] = ('like', '%%%s%%' % txt) + + return frappe.get_all('BOM Operation', + filters = filters, fields = ['operation'], as_list=1) + @frappe.whitelist() def get_item_details(item, project = None): res = frappe.db.sql("""