'rename serial_no text fields'

def after_rename(self, old, new, merge=False):

    for dt in frappe.db.sql(u"select    parent    from    tabDocField\n DCTB  DCTB  DCTB where    fieldname='serial_no'    and    fieldtype    in    ('Text',    'Small    Text')"):
        for item in frappe.db.sql((u"select    name,    serial_no    from    `tab%s`\n DCTB  DCTB  DCTB  DCTB where    serial_no    like    '%%%s%%'" % (dt[0], frappe.db.escape(old)))):
            serial_nos = map((lambda i: (new if (i.upper() == old.upper()) else i)), item[1].split(u'\n'))
            frappe.db.sql((u'update    `tab%s`    set    serial_no    =    %s\n DCTB  DCTB  DCTB  DCTB  DCTB where    name=%s' % (dt[0], u'%s', u'%s')), (u'\n'.join(serial_nos), item[0]))
