Skip to content

Commit 97ec343

Browse files
fix: do not reset picked items
1 parent 7fed467 commit 97ec343

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

erpnext/stock/doctype/pick_list/pick_list.py

+26-10
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@ def onload(self) -> None:
7474

7575
def validate(self):
7676
self.validate_for_qty()
77-
if self.pick_manually and self.get("locations"):
78-
self.validate_stock_qty()
79-
self.check_serial_no_status()
77+
self.validate_stock_qty()
78+
self.check_serial_no_status()
8079

8180
def before_save(self):
8281
self.update_status()
@@ -90,14 +89,21 @@ def validate_stock_qty(self):
9089
from erpnext.stock.doctype.batch.batch import get_batch_qty
9190

9291
for row in self.get("locations"):
93-
if row.batch_no and not row.qty:
92+
if row.batch_no and row.picked_qty:
9493
batch_qty = get_batch_qty(row.batch_no, row.warehouse, row.item_code)
9594

96-
if row.qty > batch_qty:
95+
if row.picked_qty > batch_qty:
9796
frappe.throw(
9897
_(
99-
"At Row #{0}: The picked quantity {1} for the item {2} is greater than available stock {3} for the batch {4} in the warehouse {5}."
100-
).format(row.idx, row.item_code, batch_qty, row.batch_no, bold(row.warehouse)),
98+
"At Row #{0}: The picked quantity {1} for the item {2} is greater than available stock {3} for the batch {4} in the warehouse {5}. Please restock the item."
99+
).format(
100+
row.idx,
101+
row.picked_qty,
102+
row.item_code,
103+
batch_qty,
104+
row.batch_no,
105+
bold(row.warehouse),
106+
),
101107
title=_("Insufficient Stock"),
102108
)
103109

@@ -109,11 +115,11 @@ def validate_stock_qty(self):
109115
"actual_qty",
110116
)
111117

112-
if row.qty > flt(bin_qty):
118+
if row.picked_qty > flt(bin_qty):
113119
frappe.throw(
114120
_(
115121
"At Row #{0}: The picked quantity {1} for the item {2} is greater than available stock {3} in the warehouse {4}."
116-
).format(row.idx, row.qty, bold(row.item_code), bin_qty, bold(row.warehouse)),
122+
).format(row.idx, row.picked_qty, bold(row.item_code), bin_qty, bold(row.warehouse)),
117123
title=_("Insufficient Stock"),
118124
)
119125

@@ -429,7 +435,14 @@ def set_item_locations(self, save=False):
429435
locations_replica = self.get("locations")
430436

431437
# reset
432-
self.delete_key("locations")
438+
reset_rows = []
439+
for row in self.get("locations"):
440+
if not row.picked_qty:
441+
reset_rows.append(row)
442+
443+
for row in reset_rows:
444+
self.remove(row)
445+
433446
updated_locations = frappe._dict()
434447
for item_doc in items:
435448
item_code = item_doc.item_code
@@ -499,6 +512,9 @@ def aggregate_item_qty(self):
499512
# aggregate qty for same item
500513
item_map = OrderedDict()
501514
for item in locations:
515+
if item.picked_qty:
516+
continue
517+
502518
if not item.item_code:
503519
frappe.throw(f"Row #{item.idx}: Item Code is Mandatory")
504520
if not cint(

0 commit comments

Comments
 (0)