mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-14 12:25:09 +00:00
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:
@@ -82,6 +82,7 @@ class RepostItemValuation(Document):
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
self.reset_repost_only_accounting_ledgers()
|
self.reset_repost_only_accounting_ledgers()
|
||||||
self.set_company()
|
self.set_company()
|
||||||
|
self.validate_update_stock()
|
||||||
self.validate_period_closing_voucher()
|
self.validate_period_closing_voucher()
|
||||||
self.set_status(write=False)
|
self.set_status(write=False)
|
||||||
self.reset_field_values()
|
self.reset_field_values()
|
||||||
@@ -93,6 +94,18 @@ class RepostItemValuation(Document):
|
|||||||
if self.repost_only_accounting_ledgers and self.based_on != "Transaction":
|
if self.repost_only_accounting_ledgers and self.based_on != "Transaction":
|
||||||
self.repost_only_accounting_ledgers = 0
|
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):
|
def validate_recreate_stock_ledgers(self):
|
||||||
if not self.recreate_stock_ledgers:
|
if not self.recreate_stock_ledgers:
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user