fix: validate only for stock transactions
This commit is contained in:
parent
776d8f72cf
commit
3d91d48b77
@ -32,7 +32,21 @@ class TransactionBase(StatusUpdater):
|
|||||||
self.validate_future_posting()
|
self.validate_future_posting()
|
||||||
self.validate_with_last_transaction_posting_time()
|
self.validate_with_last_transaction_posting_time()
|
||||||
|
|
||||||
|
def is_stock_transaction(self):
|
||||||
|
if self.doctype not in ["Sales Invoice", "Purchase Invoice", "Stock Entry", "Stock Reconciliation",
|
||||||
|
"Delivery Note", "Purchase Receipt", "Fees"]:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if self.doctype in ["Sales Invoice", "Purchase Invoice"]:
|
||||||
|
if not (self.get("update_stock") or self.get("is_pos")):
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def validate_future_posting(self):
|
def validate_future_posting(self):
|
||||||
|
if not self.is_stock_transaction():
|
||||||
|
return
|
||||||
|
|
||||||
if getattr(self, 'set_posting_time', None) and date_diff(self.posting_date, nowdate()) > 0:
|
if getattr(self, 'set_posting_time', None) and date_diff(self.posting_date, nowdate()) > 0:
|
||||||
msg = _("Posting future transactions are not allowed due to Immutable Ledger")
|
msg = _("Posting future transactions are not allowed due to Immutable Ledger")
|
||||||
frappe.throw(msg, title=_("Future Posting Not Allowed"))
|
frappe.throw(msg, title=_("Future Posting Not Allowed"))
|
||||||
@ -168,12 +182,7 @@ class TransactionBase(StatusUpdater):
|
|||||||
|
|
||||||
def validate_with_last_transaction_posting_time(self):
|
def validate_with_last_transaction_posting_time(self):
|
||||||
|
|
||||||
if self.doctype not in ["Sales Invoice", "Purchase Invoice", "Stock Entry", "Stock Reconciliation",
|
if not self.is_stock_transaction():
|
||||||
"Delivery Note", "Purchase Receipt", "Fees"]:
|
|
||||||
return
|
|
||||||
|
|
||||||
if self.doctype in ["Sales Invoice", "Purchase Invoice"]:
|
|
||||||
if not (self.get("update_stock") or self.get("is_pos")):
|
|
||||||
return
|
return
|
||||||
|
|
||||||
for item in self.get('items'):
|
for item in self.get('items'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user