mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-09 16:21:19 +00:00
fix: Add indexes in stock queries
This commit is contained in:
@@ -591,7 +591,7 @@ def future_sle_exists(args, sl_entries=None):
|
||||
|
||||
data = frappe.db.sql("""
|
||||
select item_code, warehouse, count(name) as total_row
|
||||
from `tabStock Ledger Entry`
|
||||
from `tabStock Ledger Entry` force index (item_warehouse)
|
||||
where
|
||||
({})
|
||||
and timestamp(posting_date, posting_time)
|
||||
|
||||
@@ -182,3 +182,4 @@ def on_doctype_update():
|
||||
frappe.db.add_index("Stock Ledger Entry", ["voucher_no", "voucher_type"])
|
||||
frappe.db.add_index("Stock Ledger Entry", ["batch_no", "item_code", "warehouse"])
|
||||
frappe.db.add_index("Stock Ledger Entry", ["voucher_detail_no"])
|
||||
frappe.db.add_index("Stock Ledger Entry", ["item_code", "warehouse"], "item_warehouse")
|
||||
|
||||
@@ -910,7 +910,7 @@ def get_valuation_rate(item_code, warehouse, voucher_type, voucher_no,
|
||||
company = erpnext.get_default_company()
|
||||
|
||||
last_valuation_rate = frappe.db.sql("""select valuation_rate
|
||||
from `tabStock Ledger Entry`
|
||||
from `tabStock Ledger Entry` force index (item_warehouse)
|
||||
where
|
||||
item_code = %s
|
||||
AND warehouse = %s
|
||||
@@ -921,7 +921,7 @@ def get_valuation_rate(item_code, warehouse, voucher_type, voucher_no,
|
||||
if not last_valuation_rate:
|
||||
# Get valuation rate from last sle for the item against any warehouse
|
||||
last_valuation_rate = frappe.db.sql("""select valuation_rate
|
||||
from `tabStock Ledger Entry`
|
||||
from `tabStock Ledger Entry` force index (item_code)
|
||||
where
|
||||
item_code = %s
|
||||
AND valuation_rate > 0
|
||||
|
||||
Reference in New Issue
Block a user