From 57cf3c28f896bf619563917d63b6f718ef5c8cbe Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 20 Jul 2023 20:11:05 +0530 Subject: [PATCH] fix: made item or warehouse filter mandatory (backport #36208) (#36215) fix: made item or warehouse filter mandatory (cherry picked from commit 16498627cec1e416fcc9a911b11ca522268eb622) Co-authored-by: Rohit Waghchaure --- .../batch_wise_balance_history.py | 7 +++++++ 1 file changed, 7 insertions(+) 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 0d57938e31f..0f319554763 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 @@ -9,11 +9,18 @@ from pypika import functions as fn 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"))