def get_valid_serial_nos(sr_nos, qty=0, item_code=u''):
 serial_nos = cstr(sr_nos).strip().replace(u',', u'\n').split(u'\n')
 valid_serial_nos = []
 for val in serial_nos:
  if val:
   val = val.strip()
   if (val in valid_serial_nos):
    frappe.throw(_(u'Serial number {0} entered more than once').format(val))
   else:
    valid_serial_nos.append(val)
 if (qty and (len(valid_serial_nos) != abs(qty))):
  frappe.throw(_(u'{0} valid serial nos for Item {1}').format(abs(qty), item_code))
 return valid_serial_nos

def get_valid_serial_nos ( sr_nos , qty = 0 , item_code = u'' ) : serial_nos = cstr ( sr_nos ) . strip ( ) . replace ( u',' , u'\n' ) . split ( u'\n' ) valid_serial_nos = [ ] for val in serial_nos : if val : val = val . strip ( ) if ( val in valid_serial_nos ) : frappe . throw ( _ ( u'Serial number {0} entered more than once' ) . format ( val ) ) else : valid_serial_nos . append ( val ) if ( qty and ( len ( valid_serial_nos ) != abs ( qty ) ) ) : frappe . throw ( _ ( u'{0} valid serial nos for Item {1}' ) . format ( abs ( qty ) , item_code ) ) return valid_serial_nos
split serial nos .