From 9b42682575fa55fdda507670d70db9b3c4d52da9 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 29 Aug 2019 21:14:26 +0530 Subject: [PATCH] fix: Check parent warehouse for batch as well --- erpnext/stock/doctype/pick_list/pick_list.json | 3 ++- erpnext/stock/doctype/pick_list/pick_list.py | 7 +++++-- erpnext/stock/doctype/pick_list_item/pick_list_item.json | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/erpnext/stock/doctype/pick_list/pick_list.json b/erpnext/stock/doctype/pick_list/pick_list.json index e635db0540..8d5ef3d12a 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.json +++ b/erpnext/stock/doctype/pick_list/pick_list.json @@ -96,6 +96,7 @@ "options": "Material Request" }, { + "depends_on": "eval:doc.docstatus===0", "fieldname": "get_item_locations", "fieldtype": "Button", "label": "Get Item Locations" @@ -110,7 +111,7 @@ } ], "is_submittable": 1, - "modified": "2019-08-28 12:49:59.800807", + "modified": "2019-08-29 21:10:11.572387", "modified_by": "Administrator", "module": "Stock", "name": "Pick List", diff --git a/erpnext/stock/doctype/pick_list/pick_list.py b/erpnext/stock/doctype/pick_list/pick_list.py index efe6da8e15..128ad2504d 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.py +++ b/erpnext/stock/doctype/pick_list/pick_list.py @@ -170,6 +170,7 @@ def get_available_item_locations_for_serialized_item(item_code, from_warehouses, return locations def get_available_item_locations_for_batched_item(item_code, from_warehouses, required_qty): + warehouse_condition = 'and warehouse in %(warehouses)s' if from_warehouses else '' batch_locations = frappe.db.sql(""" SELECT sle.`warehouse`, @@ -181,15 +182,17 @@ def get_available_item_locations_for_batched_item(item_code, from_warehouses, re sle.batch_no = batch.name and sle.`item_code`=%(item_code)s and IFNULL(batch.`expiry_date`, '2200-01-01') > %(today)s + {warehouse_condition} GROUP BY `warehouse`, `batch_no`, `item_code` HAVING `qty` > 0 ORDER BY IFNULL(batch.`expiry_date`, '2200-01-01'), batch.`creation` - """, { + """.format(warehouse_condition=warehouse_condition), { #nosec 'item_code': item_code, - 'today': today() + 'today': today(), + 'warehouses': from_warehouses }, as_dict=1) total_qty_available = sum(location.get('qty') for location in batch_locations) diff --git a/erpnext/stock/doctype/pick_list_item/pick_list_item.json b/erpnext/stock/doctype/pick_list_item/pick_list_item.json index 552764dc2f..9ecdecdaa0 100644 --- a/erpnext/stock/doctype/pick_list_item/pick_list_item.json +++ b/erpnext/stock/doctype/pick_list_item/pick_list_item.json @@ -111,7 +111,7 @@ "fieldname": "stock_qty", "fieldtype": "Float", "in_list_view": 1, - "label": "Qty (Stock UOM)", + "label": "Stock Qty", "read_only": 1 }, { @@ -168,7 +168,7 @@ } ], "istable": 1, - "modified": "2019-08-28 15:56:14.507776", + "modified": "2019-08-29 17:17:17.668199", "modified_by": "Administrator", "module": "Stock", "name": "Pick List Item",