fix: Check parent warehouse for batch as well

This commit is contained in:
Suraj Shetty 2019-08-29 21:14:26 +05:30
parent a6ab00162e
commit 9b42682575
3 changed files with 9 additions and 5 deletions

View File

@ -96,6 +96,7 @@
"options": "Material Request" "options": "Material Request"
}, },
{ {
"depends_on": "eval:doc.docstatus===0",
"fieldname": "get_item_locations", "fieldname": "get_item_locations",
"fieldtype": "Button", "fieldtype": "Button",
"label": "Get Item Locations" "label": "Get Item Locations"
@ -110,7 +111,7 @@
} }
], ],
"is_submittable": 1, "is_submittable": 1,
"modified": "2019-08-28 12:49:59.800807", "modified": "2019-08-29 21:10:11.572387",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Pick List", "name": "Pick List",

View File

@ -170,6 +170,7 @@ def get_available_item_locations_for_serialized_item(item_code, from_warehouses,
return locations return locations
def get_available_item_locations_for_batched_item(item_code, from_warehouses, required_qty): 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(""" batch_locations = frappe.db.sql("""
SELECT SELECT
sle.`warehouse`, sle.`warehouse`,
@ -181,15 +182,17 @@ def get_available_item_locations_for_batched_item(item_code, from_warehouses, re
sle.batch_no = batch.name sle.batch_no = batch.name
and sle.`item_code`=%(item_code)s and sle.`item_code`=%(item_code)s
and IFNULL(batch.`expiry_date`, '2200-01-01') > %(today)s and IFNULL(batch.`expiry_date`, '2200-01-01') > %(today)s
{warehouse_condition}
GROUP BY GROUP BY
`warehouse`, `warehouse`,
`batch_no`, `batch_no`,
`item_code` `item_code`
HAVING `qty` > 0 HAVING `qty` > 0
ORDER BY IFNULL(batch.`expiry_date`, '2200-01-01'), batch.`creation` ORDER BY IFNULL(batch.`expiry_date`, '2200-01-01'), batch.`creation`
""", { """.format(warehouse_condition=warehouse_condition), { #nosec
'item_code': item_code, 'item_code': item_code,
'today': today() 'today': today(),
'warehouses': from_warehouses
}, as_dict=1) }, as_dict=1)
total_qty_available = sum(location.get('qty') for location in batch_locations) total_qty_available = sum(location.get('qty') for location in batch_locations)

View File

@ -111,7 +111,7 @@
"fieldname": "stock_qty", "fieldname": "stock_qty",
"fieldtype": "Float", "fieldtype": "Float",
"in_list_view": 1, "in_list_view": 1,
"label": "Qty (Stock UOM)", "label": "Stock Qty",
"read_only": 1 "read_only": 1
}, },
{ {
@ -168,7 +168,7 @@
} }
], ],
"istable": 1, "istable": 1,
"modified": "2019-08-28 15:56:14.507776", "modified": "2019-08-29 17:17:17.668199",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Pick List Item", "name": "Pick List Item",