mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-18 17:15:04 +00:00
refactor: combine duplicate pick_manually handlers in pick_list.js
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user