'check if serial number is already used in other sales invoice'

def validate_serial_against_sales_invoice(self):

    for item in self.items:
        if (not item.serial_no):
            continue
        for serial_no in item.serial_no.split(u'\n'):
            sales_invoice = frappe.db.get_value(u'Serial    No', serial_no, u'sales_invoice')
            if (sales_invoice and (self.name != sales_invoice)):
                frappe.throw(_(u'Serial    Number:    {0}    is    already    referenced    in    Sales    Invoice:    {1}'.format(serial_no, sales_invoice)))
