From af81ed874b13c0bda088ff8728bab7524410c035 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 6 Apr 2026 15:17:11 +0000 Subject: [PATCH] fix: transactions where update stock is 0 should not create SLEs (backport #54035) (#54077) Co-authored-by: Nishka Gosalia <58264710+nishkagosalia@users.noreply.github.com> fix: transactions where update stock is 0 should not create SLEs (#54035) --- .../repost_item_valuation/repost_item_valuation.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py index 2b4d5c28692..84cf6234dcf 100644 --- a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py +++ b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py @@ -82,6 +82,7 @@ class RepostItemValuation(Document): def validate(self): self.reset_repost_only_accounting_ledgers() self.set_company() + self.validate_update_stock() self.validate_period_closing_voucher() self.set_status(write=False) self.reset_field_values() @@ -93,6 +94,18 @@ class RepostItemValuation(Document): if self.repost_only_accounting_ledgers and self.based_on != "Transaction": self.repost_only_accounting_ledgers = 0 + def validate_update_stock(self): + if ( + self.voucher_type in ["Sales Invoice", "Purchase Invoice"] + and not self.repost_only_accounting_ledgers + ): + update_stock = frappe.get_value(self.voucher_type, self.voucher_no, "update_stock") + if not update_stock: + msg = _( + "Since {0} has 'Update Stock' disabled, you cannot create repost item valuation against it" + ).format(get_link_to_form(self.voucher_type, self.voucher_no)) + frappe.throw(msg) + def validate_recreate_stock_ledgers(self): if not self.recreate_stock_ledgers: return