fix: Serial no validation against sales invoice

This commit is contained in:
deepeshgarg007 2019-11-26 15:13:23 +05:30
parent e0912e4fcc
commit 45f57f273c

View File

@ -1048,9 +1048,14 @@ class SalesInvoice(SellingController):
continue continue
for serial_no in item.serial_no.split("\n"): for serial_no in item.serial_no.split("\n"):
sales_invoice, item_code = frappe.db.get_value("Serial No", serial_no, serial_no_details = frappe.db.get_value("Serial No", serial_no,
["sales_invoice", "item_code"]) ["sales_invoice", "item_code"], as_dict=1)
if sales_invoice and item_code == item.item_code and self.name != sales_invoice:
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") sales_invoice_company = frappe.db.get_value("Sales Invoice", sales_invoice, "company")
if sales_invoice_company == self.company: if sales_invoice_company == self.company:
frappe.throw(_("Serial Number: {0} is already referenced in Sales Invoice: {1}" frappe.throw(_("Serial Number: {0} is already referenced in Sales Invoice: {1}"