fix: Serial no validation against sales invoice
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 70a80ca..9d2f133 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -1048,9 +1048,14 @@
continue
for serial_no in item.serial_no.split("\n"):
- sales_invoice, item_code = frappe.db.get_value("Serial No", serial_no,
- ["sales_invoice", "item_code"])
- if sales_invoice and item_code == item.item_code and self.name != sales_invoice:
+ serial_no_details = frappe.db.get_value("Serial No", serial_no,
+ ["sales_invoice", "item_code"], as_dict=1)
+
+ if not serial_no_details:
+ continue
+
+ if serial_no_details.sales_invoice and serial_no_details.item_code == item.item_code \
+ and self.name != serial_no_details.sales_invoice:
sales_invoice_company = frappe.db.get_value("Sales Invoice", sales_invoice, "company")
if sales_invoice_company == self.company:
frappe.throw(_("Serial Number: {0} is already referenced in Sales Invoice: {1}"