From 3a6e17a03dcdde388c18fdfa8fd7484e1b4921cf Mon Sep 17 00:00:00 2001 From: Sudharsanan Ashok <135326972+Sudharsanan11@users.noreply.github.com> Date: Wed, 19 Aug 2026 10:27:07 +0530 Subject: [PATCH] fix(stock): fetch item stock UOM in stock reconciliation (#58284) --- .../stock_reconciliation/stock_reconciliation.py | 11 +++++++++-- .../stock_reconciliation/test_stock_reconciliation.py | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index b51e52c98bb..8109aad927e 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -1317,12 +1317,15 @@ def get_item_and_warehouses(item_code, warehouse): from frappe.utils.nestedset import get_descendants_of items = [] + stock_uom = frappe.get_cached_value("Item", item_code, "stock_uom") if frappe.get_cached_value("Warehouse", warehouse, "is_group"): childrens = get_descendants_of("Warehouse", warehouse, ignore_permissions=True, order_by="lft") for ch_warehouse in childrens: - items.append(frappe._dict({"item_code": item_code, "warehouse": ch_warehouse})) + items.append( + frappe._dict({"item_code": item_code, "warehouse": ch_warehouse, "stock_uom": stock_uom}) + ) else: - items = [frappe._dict({"item_code": item_code, "warehouse": warehouse})] + items = [frappe._dict({"item_code": item_code, "warehouse": warehouse, "stock_uom": stock_uom})] return items @@ -1349,6 +1352,7 @@ def get_items_for_stock_reco(warehouse, company): bin_dt.warehouse.as_("warehouse"), item.has_serial_no, item.has_batch_no, + item.stock_uom, ) .where( ((item.disabled == 0) | item.disabled.isnull()) @@ -1373,6 +1377,7 @@ def get_items_for_stock_reco(warehouse, company): item_default.default_warehouse.as_("warehouse"), item.has_serial_no, item.has_batch_no, + item.stock_uom, ) .where( item_default.default_warehouse.isin(warehouses_in_tree) @@ -1412,6 +1417,7 @@ def get_item_data(row, qty, valuation_rate, serial_no=None): "current_serial_no": serial_no, "serial_no": serial_no, "batch_no": row.get("batch_no"), + "stock_uom": row.get("stock_uom"), } @@ -1439,6 +1445,7 @@ def get_itemwise_batch(warehouse, posting_date, company, item_code=None): "valuation_rate": row[9], "item_name": row[1], "batch_no": row[4], + "stock_uom": row[11], } ) ) diff --git a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py index 0054a7bdf52..cee42f51c4d 100644 --- a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py @@ -140,6 +140,7 @@ class TestStockReconciliation(ERPNextTestSuite, StockTestMixin): "_Test Stock Reco Item", is_stock_item=1, valuation_rate=100, + stock_uom="_Test UOM", warehouse="_Test Warehouse Ledger 1 - _TC", opening_stock=100, ) @@ -147,8 +148,8 @@ class TestStockReconciliation(ERPNextTestSuite, StockTestMixin): items = get_items("_Test Warehouse Group 1 - _TC", nowdate(), nowtime(), "_Test Company") self.assertEqual( - ["_Test Stock Reco Item", "_Test Warehouse Ledger 1 - _TC", 100], - [items[0]["item_code"], items[0]["warehouse"], items[0]["qty"]], + ["_Test Stock Reco Item", "_Test Warehouse Ledger 1 - _TC", 100, "_Test UOM"], + [items[0]["item_code"], items[0]["warehouse"], items[0]["qty"], items[0]["stock_uom"]], ) def test_stock_reco_for_serialized_item(self):