mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 00:44:45 +00:00
Update batch.py (#14905)
* Update batch.py Performance improvements for pos stock availability checks on a particular warehouse due to the slowing down effects of the where clauses combined by the "and". * Update batch.py
This commit is contained in:
@@ -251,8 +251,8 @@ def get_batch_no(item_code, warehouse, qty=1, throw=False):
|
|||||||
|
|
||||||
def get_batches(item_code, warehouse, qty=1, throw=False):
|
def get_batches(item_code, warehouse, qty=1, throw=False):
|
||||||
batches = frappe.db.sql(
|
batches = frappe.db.sql(
|
||||||
'select batch_id, sum(actual_qty) as qty from `tabBatch` join `tabStock Ledger Entry` '
|
'select batch_id, sum(actual_qty) as qty from `tabBatch` join `tabStock Ledger Entry` ignore index (item_code, warehouse) '
|
||||||
'on `tabBatch`.batch_id = `tabStock Ledger Entry`.batch_no '
|
'on `(tabBatch`.batch_id = `tabStock Ledger Entry`.batch_no )'
|
||||||
'where `tabStock Ledger Entry`.item_code = %s and `tabStock Ledger Entry`.warehouse = %s '
|
'where `tabStock Ledger Entry`.item_code = %s and `tabStock Ledger Entry`.warehouse = %s '
|
||||||
'and (`tabBatch`.expiry_date >= CURDATE() or `tabBatch`.expiry_date IS NULL)'
|
'and (`tabBatch`.expiry_date >= CURDATE() or `tabBatch`.expiry_date IS NULL)'
|
||||||
'group by batch_id '
|
'group by batch_id '
|
||||||
|
|||||||
Reference in New Issue
Block a user