mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-18 09:05:00 +00:00
Merge pull request #50645 from frappe/mergify/bp/version-15-hotfix/pr-50644
fix: validation for SABB deletion (backport #50644)
This commit is contained in:
@@ -1347,7 +1347,36 @@ class SerialandBatchBundle(Document):
|
||||
if self.voucher_type == "POS Invoice":
|
||||
return
|
||||
|
||||
if frappe.db.get_value(self.voucher_type, self.voucher_no, "docstatus") == 1:
|
||||
child_doctype = self.voucher_type + " Item"
|
||||
mapper = {
|
||||
"Asset Capitalization": "Asset Capitalization Stock Item",
|
||||
"Asset Repair": "Asset Repair Consumed Item",
|
||||
"Stock Entry": "Stock Entry Detail",
|
||||
}.get(self.voucher_type)
|
||||
|
||||
if mapper:
|
||||
child_doctype = mapper
|
||||
|
||||
if self.voucher_type == "Delivery Note" and not frappe.db.exists(
|
||||
"Delivery Note Item", self.voucher_detail_no
|
||||
):
|
||||
child_doctype = "Packed Item"
|
||||
|
||||
elif self.voucher_type == "Sales Invoice" and not frappe.db.exists(
|
||||
"Sales Invoice Item", self.voucher_detail_no
|
||||
):
|
||||
child_doctype = "Packed Item"
|
||||
|
||||
elif self.voucher_type == "Subcontracting Receipt" and not frappe.db.exists(
|
||||
"Subcontracting Receipt Item", self.voucher_detail_no
|
||||
):
|
||||
child_doctype = "Subcontracting Receipt Supplied Item"
|
||||
|
||||
if (
|
||||
frappe.db.get_value(self.voucher_type, self.voucher_no, "docstatus") == 1
|
||||
and self.voucher_detail_no
|
||||
and frappe.db.exists(child_doctype, self.voucher_detail_no)
|
||||
):
|
||||
msg = f"""The {self.voucher_type} {bold(self.voucher_no)}
|
||||
is in submitted state, please cancel it first"""
|
||||
frappe.throw(_(msg))
|
||||
|
||||
Reference in New Issue
Block a user