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)
This commit is contained in:
mergify[bot]
2026-04-06 15:17:11 +00:00
committed by GitHub
parent 14868ab98f
commit af81ed874b

View File

@@ -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