From fe65882e59bb7cd4fc4acb42c1d47896f17d0b31 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Mon, 20 Jul 2026 19:59:13 +0530 Subject: [PATCH] fix: keep Standard Cost stock value in step with the standard rate Mirrors update_qty's Standard Cost handling and drops fixed test item names so reruns start from fresh SLE-less items. (cherry picked from commit 49a43aad81cfcaebdb5f69f56cace5aee49bad04) --- erpnext/stock/doctype/bin/bin.py | 9 +++++++++ erpnext/stock/doctype/bin/test_bin.py | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/bin/bin.py b/erpnext/stock/doctype/bin/bin.py index ae3b06d22ea..64004b13d19 100644 --- a/erpnext/stock/doctype/bin/bin.py +++ b/erpnext/stock/doctype/bin/bin.py @@ -50,6 +50,15 @@ class Bin(Document): self.actual_qty = last_sle.qty_after_transaction self.valuation_rate = last_sle.valuation_rate self.stock_value = last_sle.stock_value + + from erpnext.stock.utils import get_valuation_method + + if get_valuation_method(self.item_code) == "Standard Cost": + from erpnext.stock.doctype.item_standard_cost.item_standard_cost import get_item_standard_rate + + self.stock_value = flt(self.actual_qty) * flt( + get_item_standard_rate(self.item_code, self.company) + ) self.planned_qty = get_planned_qty(self.item_code, self.warehouse) self.indented_qty = get_indented_qty(self.item_code, self.warehouse) self.ordered_qty = get_ordered_qty(self.item_code, self.warehouse) diff --git a/erpnext/stock/doctype/bin/test_bin.py b/erpnext/stock/doctype/bin/test_bin.py index 92f8c6bbaaa..45302c66f01 100644 --- a/erpnext/stock/doctype/bin/test_bin.py +++ b/erpnext/stock/doctype/bin/test_bin.py @@ -29,7 +29,7 @@ class TestBin(ERPNextTestSuite): def test_recalculate_values(self): from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry - item_code = make_item("_TestBinRecalculateValues").name + item_code = make_item().name warehouse = "_Test Warehouse - _TC" make_stock_entry(item_code=item_code, target=warehouse, qty=10, rate=100) @@ -43,7 +43,7 @@ class TestBin(ERPNextTestSuite): self.assertEqual(bin.stock_value, 1000) def test_recalculate_values_without_sle(self): - item_code = make_item("_TestBinRecalculateValuesNoSLE").name + item_code = make_item().name warehouse = "_Test Warehouse - _TC" bin = _create_bin(item_code, warehouse)