From 4e37ed9033f0374729593b9286b47cbee20e319b Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Fri, 31 May 2024 11:55:51 +0530 Subject: [PATCH] fix: key error for stock ledger report (#41700) --- erpnext/stock/report/stock_ledger/stock_ledger.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/report/stock_ledger/stock_ledger.py b/erpnext/stock/report/stock_ledger/stock_ledger.py index 1a50e3dea893..2920ebf69e8c 100644 --- a/erpnext/stock/report/stock_ledger/stock_ledger.py +++ b/erpnext/stock/report/stock_ledger/stock_ledger.py @@ -67,7 +67,12 @@ def execute(filters=None): if filters.get("batch_no") or inventory_dimension_filters_applied: actual_qty += flt(sle.actual_qty, precision) stock_value += sle.stock_value_difference - batch_balance_dict[sle.batch_no] += sle.actual_qty + if sle.batch_no: + if not batch_balance_dict.get(sle.batch_no): + batch_balance_dict[sle.batch_no] = 0 + + batch_balance_dict[sle.batch_no] += sle.actual_qty + if filters.get("segregate_serial_batch_bundle"): actual_qty = batch_balance_dict[sle.batch_no]