mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-14 04:15:10 +00:00
Merge pull request #51958 from mihir-kandoi/force-serial-batch-stock-reco
This commit is contained in:
@@ -665,6 +665,16 @@ class StockReconciliation(StockController):
|
||||
validate_is_stock_item,
|
||||
)
|
||||
|
||||
def validate_serial_batch_items():
|
||||
has_batch_no, has_serial_no = frappe.get_value(
|
||||
"Item", item_code, ["has_batch_no", "has_serial_no"]
|
||||
)
|
||||
if row.use_serial_batch_fields and self.purpose == "Stock Reconciliation":
|
||||
if has_batch_no and not row.batch_no:
|
||||
raise frappe.ValidationError(_("Please enter Batch No"))
|
||||
if has_serial_no and not row.serial_no:
|
||||
raise frappe.ValidationError(_("Please enter Serial No"))
|
||||
|
||||
# using try except to catch all validation msgs and display together
|
||||
|
||||
try:
|
||||
@@ -673,12 +683,13 @@ class StockReconciliation(StockController):
|
||||
# end of life and stock item
|
||||
validate_end_of_life(item_code, item.end_of_life, item.disabled)
|
||||
validate_is_stock_item(item_code, item.is_stock_item)
|
||||
validate_serial_batch_items()
|
||||
|
||||
# docstatus should be < 2
|
||||
validate_cancelled_item(item_code, item.docstatus)
|
||||
|
||||
except Exception as e:
|
||||
self.validation_messages.append(_("Row #") + " " + ("%d: " % (row.idx)) + cstr(e))
|
||||
self.validation_messages.append(_("Row #") + ("%d: " % (row.idx)) + cstr(e))
|
||||
|
||||
def validate_reserved_stock(self) -> None:
|
||||
"""Raises an exception if there is any reserved stock for the items in the Stock Reconciliation."""
|
||||
|
||||
@@ -1449,6 +1449,7 @@ class TestStockReconciliation(IntegrationTestCase, StockTestMixin):
|
||||
qty=10,
|
||||
rate=100,
|
||||
use_serial_batch_fields=1,
|
||||
purpose="Opening Stock",
|
||||
)
|
||||
|
||||
sr.reload()
|
||||
@@ -1591,6 +1592,7 @@ class TestStockReconciliation(IntegrationTestCase, StockTestMixin):
|
||||
qty=10,
|
||||
rate=80,
|
||||
use_serial_batch_fields=1,
|
||||
purpose="Opening Stock",
|
||||
)
|
||||
|
||||
batch_no = get_batch_from_bundle(reco.items[0].serial_and_batch_bundle)
|
||||
@@ -1675,6 +1677,7 @@ class TestStockReconciliation(IntegrationTestCase, StockTestMixin):
|
||||
qty=10,
|
||||
rate=100,
|
||||
use_serial_batch_fields=1,
|
||||
purpose="Opening Stock",
|
||||
)
|
||||
|
||||
sr.reload()
|
||||
|
||||
Reference in New Issue
Block a user