fix: negative stock error for batch (#43450)
(cherry picked from commit 912ba7789c)
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -280,7 +280,7 @@ class SerialandBatchBundle(Document):
|
||||
)
|
||||
|
||||
def validate_negative_batch(self, batch_no, available_qty):
|
||||
if available_qty < 0:
|
||||
if available_qty < 0 and not self.is_stock_reco_for_valuation_adjustment(available_qty):
|
||||
msg = f"""Batch No {bold(batch_no)} of an Item {bold(self.item_code)}
|
||||
has negative stock
|
||||
of quantity {bold(available_qty)} in the
|
||||
@@ -288,6 +288,18 @@ class SerialandBatchBundle(Document):
|
||||
|
||||
frappe.throw(_(msg), BatchNegativeStockError)
|
||||
|
||||
def is_stock_reco_for_valuation_adjustment(self, available_qty):
|
||||
if (
|
||||
self.voucher_type == "Stock Reconciliation"
|
||||
and self.type_of_transaction == "Outward"
|
||||
and self.voucher_detail_no
|
||||
and abs(frappe.db.get_value("Stock Reconciliation Item", self.voucher_detail_no, "qty"))
|
||||
== abs(available_qty)
|
||||
):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def get_sle_for_outward_transaction(self):
|
||||
sle = frappe._dict(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user