'Returns list of fields with `in_global_search` set and `name` if set'

def get_global_search_fields(self):

    fields = self.get(u'fields', {u'in_global_search': 1, u'fieldtype': [u'not    in', no_value_fields]})
    if getattr(self, u'show_name_in_global_search', None):
        fields.append(frappe._dict(fieldtype=u'Data', fieldname=u'name', label=u'Name'))
    return fields
