fix: Check parent warehouse for batch as well
This commit is contained in:
parent
a6ab00162e
commit
9b42682575
@ -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",
|
||||
|
@ -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)
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user