fix: Multiple rows for same warehouse and batches in pick list (#33456)
This commit is contained in:
parent
8263bf9a9a
commit
d2686ce75b
@ -51,7 +51,15 @@ frappe.ui.form.on('Pick List', {
|
|||||||
if (!(frm.doc.locations && frm.doc.locations.length)) {
|
if (!(frm.doc.locations && frm.doc.locations.length)) {
|
||||||
frappe.msgprint(__('Add items in the Item Locations table'));
|
frappe.msgprint(__('Add items in the Item Locations table'));
|
||||||
} else {
|
} else {
|
||||||
frm.call('set_item_locations', {save: save});
|
frappe.call({
|
||||||
|
method: "set_item_locations",
|
||||||
|
doc: frm.doc,
|
||||||
|
args: {
|
||||||
|
"save": save,
|
||||||
|
},
|
||||||
|
freeze: 1,
|
||||||
|
freeze_message: __("Setting Item Locations..."),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
get_item_locations: (frm) => {
|
get_item_locations: (frm) => {
|
||||||
|
@ -135,6 +135,7 @@ class PickList(Document):
|
|||||||
|
|
||||||
# reset
|
# reset
|
||||||
self.delete_key("locations")
|
self.delete_key("locations")
|
||||||
|
updated_locations = frappe._dict()
|
||||||
for item_doc in items:
|
for item_doc in items:
|
||||||
item_code = item_doc.item_code
|
item_code = item_doc.item_code
|
||||||
|
|
||||||
@ -155,6 +156,25 @@ class PickList(Document):
|
|||||||
for row in locations:
|
for row in locations:
|
||||||
location = item_doc.as_dict()
|
location = item_doc.as_dict()
|
||||||
location.update(row)
|
location.update(row)
|
||||||
|
key = (
|
||||||
|
location.item_code,
|
||||||
|
location.warehouse,
|
||||||
|
location.uom,
|
||||||
|
location.batch_no,
|
||||||
|
location.serial_no,
|
||||||
|
location.sales_order_item or location.material_request_item,
|
||||||
|
)
|
||||||
|
|
||||||
|
if key not in updated_locations:
|
||||||
|
updated_locations.setdefault(key, location)
|
||||||
|
else:
|
||||||
|
updated_locations[key].qty += location.qty
|
||||||
|
updated_locations[key].stock_qty += location.stock_qty
|
||||||
|
|
||||||
|
for location in updated_locations.values():
|
||||||
|
if location.picked_qty > location.stock_qty:
|
||||||
|
location.picked_qty = location.stock_qty
|
||||||
|
|
||||||
self.append("locations", location)
|
self.append("locations", location)
|
||||||
|
|
||||||
# If table is empty on update after submit, set stock_qty, picked_qty to 0 so that indicator is red
|
# If table is empty on update after submit, set stock_qty, picked_qty to 0 so that indicator is red
|
||||||
|
Loading…
x
Reference in New Issue
Block a user