Skip to content

Commit 6a66742

Browse files
fix: do not reset picked items
1 parent 7fed467 commit 6a66742

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

erpnext/stock/doctype/pick_list/pick_list.py

+29-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,24 @@ 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 not row.picked_qty:
93+
continue
94+
95+
if row.batch_no and row.picked_qty:
9496
batch_qty = get_batch_qty(row.batch_no, row.warehouse, row.item_code)
9597

96-
if row.qty > batch_qty:
98+
if row.picked_qty > batch_qty:
9799
frappe.throw(
98100
_(
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)),
101+
"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."
102+
).format(
103+
row.idx,
104+
row.picked_qty,
105+
row.item_code,
106+
batch_qty,
107+
row.batch_no,
108+
bold(row.warehouse),
109+
),
101110
title=_("Insufficient Stock"),
102111
)
103112

@@ -109,11 +118,11 @@ def validate_stock_qty(self):
109118
"actual_qty",
110119
)
111120

112-
if row.qty > flt(bin_qty):
121+
if row.picked_qty > flt(bin_qty):
113122
frappe.throw(
114123
_(
115124
"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)),
125+
).format(row.idx, row.picked_qty, bold(row.item_code), bin_qty, bold(row.warehouse)),
117126
title=_("Insufficient Stock"),
118127
)
119128

@@ -429,7 +438,14 @@ def set_item_locations(self, save=False):
429438
locations_replica = self.get("locations")
430439

431440
# reset
432-
self.delete_key("locations")
441+
reset_rows = []
442+
for row in self.get("locations"):
443+
if not row.picked_qty:
444+
reset_rows.append(row)
445+
446+
for row in reset_rows:
447+
self.remove(row)
448+
433449
updated_locations = frappe._dict()
434450
for item_doc in items:
435451
item_code = item_doc.item_code
@@ -499,6 +515,9 @@ def aggregate_item_qty(self):
499515
# aggregate qty for same item
500516
item_map = OrderedDict()
501517
for item in locations:
518+
if item.picked_qty:
519+
continue
520+
502521
if not item.item_code:
503522
frappe.throw(f"Row #{item.idx}: Item Code is Mandatory")
504523
if not cint(

0 commit comments

Comments
 (0)