def rebuild_global_search(context, static_pages=False): '''Setup help table in the current site (called after migrate)''' from frappe.utils.global_search import (get_doctypes_with_global_search, rebuild_for_doctype, get_routes_to_index, add_route_to_global_search, sync_global_search) for site in context.sites: try: frappe.init(site) frappe.connect() if static_pages: routes = get_routes_to_index() for i, route in enumerate(routes): add_route_to_global_search(route) frappe.local.request = None update_progress_bar('Rebuilding Global Search', i, len(routes)) sync_global_search() else: doctypes = get_doctypes_with_global_search() for i, doctype in enumerate(doctypes): rebuild_for_doctype(doctype) update_progress_bar('Rebuilding Global Search', i, len(doctypes)) finally: frappe.destroy()
def execute(): frappe.cache().delete_value('doctypes_with_global_search') doctypes_with_global_search = get_doctypes_with_global_search(with_child_tables=False) for i, doctype in enumerate(doctypes_with_global_search): update_progress_bar("Updating Global Search", i, len(doctypes_with_global_search)) rebuild_for_doctype(doctype)
def execute(): from frappe.website.router import get_doctypes_with_web_view from frappe.utils.global_search import rebuild_for_doctype for doctype in get_doctypes_with_web_view(): try: rebuild_for_doctype(doctype) except frappe.DoesNotExistError: pass
def test_update_fields(self): self.insert_test_events() results = global_search.search('Every Month') self.assertEquals(len(results), 0) doctype = "Event" from frappe.custom.doctype.property_setter.property_setter import make_property_setter make_property_setter(doctype, "repeat_on", "in_global_search", 1, "Int") global_search.rebuild_for_doctype(doctype) results = global_search.search('Every Month') self.assertEquals(len(results), 3)
def test_update_fields(self): self.insert_test_events() results = global_search.search('Every Month') self.assertEqual(len(results), 0) doctype = "Event" from frappe.custom.doctype.property_setter.property_setter import make_property_setter make_property_setter(doctype, "repeat_on", "in_global_search", 1, "Int") global_search.rebuild_for_doctype(doctype) results = global_search.search('Every Month') self.assertEqual(len(results), 3)
def delete_extra_global_search(): glob_search_list = frappe.db.sql("""SELECT doctype FROM __global_search GROUP BY doctype""",as_list=1) for doctype in glob_search_list: check = check_dt_exists(doctype) print("Rebuiling Global Search for " + doctype[0]) if check == 1: rebuild_for_doctype(doctype[0]) else: delete_global_search_records_for_doctype(doctype[0]) print("Completed Rebuilding Global Search for " + doctype[0])
def rebuild_global_search(context): '''Setup help table in the current site (called after migrate)''' from frappe.utils.global_search import (get_doctypes_with_global_search, rebuild_for_doctype) for site in context.sites: try: frappe.init(site) frappe.connect() doctypes = get_doctypes_with_global_search() for i, doctype in enumerate(doctypes): rebuild_for_doctype(doctype) update_progress_bar('Rebuilding Global Search', i, len(doctypes)) finally: frappe.destroy()
def rebuild_global_search(context): '''Setup help table in the current site (called after migrate)''' from frappe.utils.global_search import (get_doctypes_with_global_search, rebuild_for_doctype) for site in context.sites: try: frappe.init(site) frappe.connect() doctypes = get_doctypes_with_global_search() for i, doctype in enumerate(doctypes): rebuild_for_doctype(doctype) update_progress_bar('Rebuilding Global Search', i, len(doctypes)) finally: frappe.destroy()
def execute(): frappe.reload_doc("accounts", "doctype", "journal_entry") frappe.reload_doc("accounts", "doctype", "journal_entry_account") frappe.reload_doc("stock", "doctype", "stock_entry") # Migrate clearance_date for only Bank and Cash accounts frappe.db.sql(""" update `tabJournal Entry Account` jvd inner join `tabJournal Entry` jv on jv.name = jvd.parent inner join `tabAccount` acc on acc.name = jvd.account set jvd.clearance_date = jv.clearance_date where acc.account_type = 'Bank' or acc.account_type = 'Cash' """) # Migrate reference_no and reference_date for all account types frappe.db.sql(""" update `tabJournal Entry Account` jvd inner join `tabJournal Entry` jv on jv.name = jvd.parent set jvd.cheque_no = jv.cheque_no, jvd.cheque_date = jv.cheque_date """) # Set reference_numbers = cheque_no since we can assume no Journal Entry will have multiple cheque_nos frappe.db.sql("""update `tabJournal Entry` set reference_numbers = cheque_no""") # Rebuild global search, not sure if this is necessary rebuild_for_doctype("Journal Entry") rebuild_for_doctype("Payment Entry") rebuild_for_doctype("Stock Entry")
def update_lead_global_search(): rebuild_for_doctype('Lead')
def execute(): from frappe.website.router import get_doctypes_with_web_view from frappe.utils.global_search import rebuild_for_doctype for doctype in get_doctypes_with_web_view(): rebuild_for_doctype(doctype)
def execute(): for doctype in get_doctypes_with_global_search(with_child_tables=False): rebuild_for_doctype(doctype)