Merge pull request #36209 from mohsinalimat/patch-2
fix: Ambiguous column error while submitting stock entry
diff --git a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py
index c072874..e7d3e20 100644
--- a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py
+++ b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py
@@ -10,11 +10,18 @@
from erpnext.stock.doctype.warehouse.warehouse import apply_warehouse_filter
+SLE_COUNT_LIMIT = 10_000
+
def execute(filters=None):
if not filters:
filters = {}
+ sle_count = frappe.db.count("Stock Ledger Entry", {"is_cancelled": 0})
+
+ if sle_count > SLE_COUNT_LIMIT and not filters.get("item_code") and not filters.get("warehouse"):
+ frappe.throw(_("Please select either the Item or Warehouse filter to generate the report."))
+
if filters.from_date > filters.to_date:
frappe.throw(_("From Date must be before To Date"))