diff --git a/erpnext/stock/doctype/pick_list/pick_list.js b/erpnext/stock/doctype/pick_list/pick_list.js index 252a5d2872f..7de3ef7d51a 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.js +++ b/erpnext/stock/doctype/pick_list/pick_list.js @@ -81,26 +81,7 @@ frappe.ui.form.on("Pick List", { }; }); }, - pick_manually: (frm) => { - // Clear auto-assigned serial numbers and related fields when switching to manual picking - if (frm.doc.pick_manually && frm.doc.locations) { - let has_changes = false; - frm.doc.locations.forEach((row) => { - if (row.serial_no || row.batch_no || row.serial_and_batch_bundle) { - row.serial_no = ""; - row.batch_no = ""; - row.serial_and_batch_bundle = ""; - row.picked_qty = 0; - has_changes = true; - } - }); - - if (has_changes) { - frappe.show_alert(__("Cleared auto-assigned serial numbers and batch numbers for manual picking"), 3); - frm.refresh_field("locations"); - } - } - }, + set_item_locations: (frm, save) => { if (!(frm.doc.locations && frm.doc.locations.length)) { frappe.msgprint(__("Add items in the Item Locations table")); @@ -121,11 +102,31 @@ frappe.ui.form.on("Pick List", { }, pick_manually: function (frm) { + // Update warehouse field read-only property frm.fields_dict.locations.grid.update_docfield_property( "warehouse", "read_only", !frm.doc.pick_manually ); + + // Clear auto-assigned serial numbers and related fields when switching to manual picking + if (frm.doc.pick_manually && frm.doc.locations) { + let has_changes = false; + frm.doc.locations.forEach((row) => { + if (row.serial_no || row.batch_no || row.serial_and_batch_bundle) { + row.serial_no = ""; + row.batch_no = ""; + row.serial_and_batch_bundle = ""; + row.picked_qty = 0; + has_changes = true; + } + }); + + if (has_changes) { + frappe.show_alert(__("Cleared auto-assigned serial numbers and batch numbers for manual picking"), 3); + frm.refresh_field("locations"); + } + } }, get_item_locations: (frm) => {