'If global search settings are changed, rebuild search properties for this table'

def sync_global_search(self):

    global_search_fields_before_update = [d.fieldname for d in self.before_update.fields if d.in_global_search]
    if self.before_update.show_name_in_global_search:
        global_search_fields_before_update.append(u'name')
    global_search_fields_after_update = [d.fieldname for d in self.fields if d.in_global_search]
    if self.show_name_in_global_search:
        global_search_fields_after_update.append(u'name')
    if (set(global_search_fields_before_update) != set(global_search_fields_after_update)):
        now = ((not frappe.request) or frappe.flags.in_test or frappe.flags.in_install)
        frappe.enqueue(u'frappe.utils.global_search.rebuild_for_doctype', now=now, doctype=self.name)
