From a5c49d1e08506819a0f60296cf4dfb8035b9b921 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 9 Jul 2025 11:40:43 +0530 Subject: [PATCH] fix: stock settings save issue (cherry picked from commit 64ae1ec36705d7cc3f26516ab3f6f2219a1a784d) --- erpnext/stock/doctype/stock_settings/stock_settings.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.py b/erpnext/stock/doctype/stock_settings/stock_settings.py index 1513f48eb9f..ed76d96fd2e 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.py +++ b/erpnext/stock/doctype/stock_settings/stock_settings.py @@ -120,7 +120,11 @@ class StockSettings(Document): ) def cant_change_valuation_method(self): - previous_valuation_method = self.get_doc_before_save().get("valuation_method") + doc_before_save = self.get_doc_before_save() + if not doc_before_save: + return + + previous_valuation_method = doc_before_save.get("valuation_method") if previous_valuation_method and previous_valuation_method != self.valuation_method: # check if there are any stock ledger entries against items