diff --git a/erpnext/stock/doctype/serial_no/serial_no.js b/erpnext/stock/doctype/serial_no/serial_no.js index b12bbbdb27c..6e8363287a0 100644 --- a/erpnext/stock/doctype/serial_no/serial_no.js +++ b/erpnext/stock/doctype/serial_no/serial_no.js @@ -1,26 +1,30 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -cur_frm.add_fetch("customer", "customer_name", "customer_name"); -cur_frm.add_fetch("supplier", "supplier_name", "supplier_name"); - -cur_frm.add_fetch("item_code", "item_name", "item_name"); -cur_frm.add_fetch("item_code", "description", "description"); -cur_frm.add_fetch("item_code", "item_group", "item_group"); -cur_frm.add_fetch("item_code", "brand", "brand"); - -cur_frm.cscript.onload = function () { - cur_frm.set_query("item_code", function () { - return erpnext.queries.item({ is_stock_item: 1, has_serial_no: 1 }); - }); -}; - -frappe.ui.form.on("Serial No", "refresh", function (frm) { - frm.toggle_enable("item_code", frm.doc.__islocal); -}); - frappe.ui.form.on("Serial No", { + setup(frm) { + frm.add_fetch("customer", "customer_name", "customer_name"); + frm.add_fetch("supplier", "supplier_name", "supplier_name"); + frm.add_fetch("item_code", "item_name", "item_name"); + frm.add_fetch("item_code", "description", "description"); + frm.add_fetch("item_code", "item_group", "item_group"); + frm.add_fetch("item_code", "brand", "brand"); + + frm.set_query("item_code", function () { + return erpnext.queries.item({ is_stock_item: 1, has_serial_no: 1 }); + }); + + frm.set_query("work_order", () => { + return { + filters: { + docstatus: 1, + }, + }; + }); + }, + refresh(frm) { + frm.toggle_enable("item_code", frm.doc.__islocal); frm.trigger("view_ledgers"); },