From 6ffdeb1af8dc9debf63f15d8f1844a7fb1a35d40 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Tue, 31 Jan 2023 14:33:21 +0530 Subject: [PATCH] fix: consider `stock_qty` if `picked_qty` is zero --- erpnext/stock/doctype/pick_list/pick_list.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/pick_list/pick_list.py b/erpnext/stock/doctype/pick_list/pick_list.py index 79c6891f5d..bf3b5ddc54 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.py +++ b/erpnext/stock/doctype/pick_list/pick_list.py @@ -346,14 +346,16 @@ class PickList(Document): pi_item.item_code, pi_item.warehouse, pi_item.batch_no, - Sum(pi_item.picked_qty).as_("picked_qty"), + Sum(Case().when(pi_item.picked_qty > 0, pi_item.picked_qty).else_(pi_item.stock_qty)).as_( + "picked_qty" + ), Replace(GROUP_CONCAT(pi_item.serial_no), ",", "\n").as_("serial_no"), ) .where( (pi_item.item_code.isin([x.item_code for x in items])) - & (pi_item.docstatus != 2) - & (pi_item.picked_qty > 0) + & ((pi_item.picked_qty > 0) | (pi_item.stock_qty > 0)) & (pi.status != "Completed") + & (pi_item.docstatus != 2) ) .groupby( pi_item.item_code,