fix: validate warehouse of SABB for draft entry

(cherry picked from commit 9b8f685c82)

# Conflicts:
#	erpnext/controllers/stock_controller.py
This commit is contained in:
Rohit Waghchaure
2026-03-02 12:08:54 +05:30
committed by Mergify
parent 94afc32a8d
commit d5e25153f8
2 changed files with 49 additions and 0 deletions

View File

@@ -57,6 +57,8 @@ class StockController(AccountsController):
if not self.get("is_return"):
self.validate_inspection()
self.validate_warehouse_of_sabb()
self.validate_serialized_batch()
self.clean_serial_nos()
self.validate_customer_provided_item()
@@ -65,6 +67,52 @@ class StockController(AccountsController):
self.validate_putaway_capacity()
self.reset_conversion_factor()
<<<<<<< HEAD
=======
def on_update(self):
super().on_update()
self.check_zero_rate()
def validate_warehouse_of_sabb(self):
if self.is_internal_transfer():
return
doc_before_save = self.get_doc_before_save()
for row in self.items:
if not row.get("serial_and_batch_bundle"):
continue
sabb_details = frappe.db.get_value(
"Serial and Batch Bundle",
row.serial_and_batch_bundle,
["type_of_transaction", "warehouse", "has_serial_no"],
as_dict=True,
)
if not sabb_details:
continue
if sabb_details.type_of_transaction != "Outward":
continue
warehouse = row.get("warehouse") or row.get("s_warehouse")
if sabb_details.warehouse != warehouse:
frappe.throw(
_(
"Row #{0}: Warehouse {1} does not match with the warehouse {2} in Serial and Batch Bundle {3}."
).format(row.idx, warehouse, sabb_details.warehouse, row.serial_and_batch_bundle)
)
if self.doctype == "Stock Reconciliation":
continue
if sabb_details.has_serial_no and doc_before_save and doc_before_save.get("items"):
prev_row = doc_before_save.get("items", {"idx": row.idx})
if prev_row and prev_row[0].serial_and_batch_bundle != row.serial_and_batch_bundle:
sabb_doc = frappe.get_doc("Serial and Batch Bundle", row.serial_and_batch_bundle)
sabb_doc.validate_serial_no_status()
>>>>>>> 9b8f685c82 (fix: validate warehouse of SABB for draft entry)
def reset_conversion_factor(self):
for row in self.get("items"):
if row.uom != row.stock_uom:

View File

@@ -207,6 +207,7 @@ class StockEntry(StockController):
self.validate_uom_is_integer("uom", "qty")
self.validate_uom_is_integer("stock_uom", "transfer_qty")
self.validate_warehouse()
self.validate_warehouse_of_sabb()
self.validate_work_order()
self.validate_bom()
self.set_process_loss_qty()