'validate if the serial numbers in Sales Invoice Items are same as in
Delivery Note Item'

def validate_serial_against_delivery_note(self):

    for item in self.items:
        if ((not item.delivery_note) or (not item.dn_detail)):
            continue
        serial_nos = (frappe.db.get_value(u'Delivery    Note    Item', item.dn_detail, u'serial_no') or u'')
        dn_serial_nos = set(get_serial_nos(serial_nos))
        serial_nos = (item.serial_no or u'')
        si_serial_nos = set(get_serial_nos(serial_nos))
        if (si_serial_nos - dn_serial_nos):
            frappe.throw(_(u'Serial    Numbers    in    row    {0}    does    not    match    with    Delivery    Note'.format(item.idx)))
        if (item.serial_no and (cint(item.qty) != len(si_serial_nos))):
            frappe.throw(_(u'Row    {0}:    {1}    Serial    numbers    required    for    Item    {2}.    You    have    provided    {3}.'.format(item.idx, item.qty, item.item_code, len(si_serial_nos))))
