'extract tables from fields'

def extract_tables(self):

    self.tables = [((u'`tab' + self.doctype) + u'`')]
    if self.fields:
        for f in self.fields:
            if ((not ((u'tab' in f) and (u'.' in f))) or (u'locate(' in f)):
                continue
            table_name = f.split(u'.')[0]
            if table_name.lower().startswith(u'group_concat('):
                table_name = table_name[13:]
            if table_name.lower().startswith(u'ifnull('):
                table_name = table_name[7:]
            if (not (table_name[0] == u'`')):
                table_name = ((u'`' + table_name) + u'`')
            if (not (table_name in self.tables)):
                self.append_table(table_name)
