mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-20 03:47:11 +00:00
fix: added validation for insufficient stock during stock transfer
This commit is contained in:
@@ -738,6 +738,7 @@ class SerialBatchCreation:
|
||||
return frappe._dict({})
|
||||
|
||||
doc.save()
|
||||
self.validate_qty(doc)
|
||||
|
||||
if not hasattr(self, "do_not_submit") or not self.do_not_submit:
|
||||
doc.flags.ignore_voucher_validation = True
|
||||
@@ -767,6 +768,17 @@ class SerialBatchCreation:
|
||||
doc.save()
|
||||
return doc
|
||||
|
||||
def validate_qty(self, doc):
|
||||
if doc.type_of_transaction == "Outward":
|
||||
precision = doc.precision("total_qty")
|
||||
|
||||
total_qty = abs(flt(doc.total_qty, precision))
|
||||
required_qty = abs(flt(self.actual_qty, precision))
|
||||
|
||||
if required_qty - total_qty > 0:
|
||||
msg = f"For the item {bold(doc.item_code)}, the Avaliable qty {bold(total_qty)} is less than the Required Qty {bold(required_qty)} in the warehouse {bold(doc.warehouse)}. Please add sufficient qty in the warehouse."
|
||||
frappe.throw(msg, title=_("Insufficient Stock"))
|
||||
|
||||
def set_auto_serial_batch_entries_for_outward(self):
|
||||
from erpnext.stock.doctype.batch.batch import get_available_batches
|
||||
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos_for_outward
|
||||
|
||||
Reference in New Issue
Block a user