diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index efd4a289dd..e192e76318 100755 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -29,7 +29,8 @@ "options": "Supplier", "permlevel": 0, "print_hide": 1, - "read_only": 0 + "read_only": 0, + "search_index": 1 }, { "depends_on": "supplier", @@ -112,7 +113,7 @@ "print_hide": 1, "read_only": 0, "reqd": 0, - "search_index": 1 + "search_index": 0 }, { "fieldname": "bill_date", @@ -125,7 +126,7 @@ "print_hide": 1, "read_only": 0, "reqd": 0, - "search_index": 1 + "search_index": 0 }, { "fieldname": "amended_from", @@ -151,7 +152,7 @@ "permlevel": 0, "print_hide": 1, "read_only": 0, - "search_index": 1 + "search_index": 0 }, { "fieldname": "currency_and_price_list", @@ -556,7 +557,7 @@ "permlevel": 0, "print_hide": 1, "read_only": 1, - "search_index": 1 + "search_index": 0 }, { "fieldname": "write_off_amount", @@ -733,7 +734,7 @@ "permlevel": 0, "print_hide": 1, "read_only": 0, - "search_index": 1 + "search_index": 0 }, { "allow_on_submit": 1, @@ -760,7 +761,7 @@ "permlevel": 0, "print_hide": 1, "read_only": 0, - "search_index": 1 + "search_index": 0 }, { "fieldname": "mode_of_payment", @@ -789,7 +790,7 @@ "permlevel": 0, "print_hide": 1, "read_only": 0, - "search_index": 1 + "search_index": 0 }, { "fieldname": "remarks", @@ -930,7 +931,7 @@ "icon": "icon-file-text", "idx": 1, "is_submittable": 1, - "modified": "2015-06-15 15:38:19.220184", + "modified": "2015-06-16 16:46:47.308287", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice", diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index 26aa13e029..a021be41d2 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -38,7 +38,8 @@ "options": "Customer", "permlevel": 0, "print_hide": 1, - "read_only": 0 + "read_only": 0, + "search_index": 1 }, { "depends_on": "customer", @@ -880,7 +881,7 @@ "options": "Project", "permlevel": 0, "read_only": 0, - "search_index": 1 + "search_index": 0 }, { "depends_on": "eval:doc.source == 'Campaign'", @@ -1243,7 +1244,7 @@ "icon": "icon-file-text", "idx": 1, "is_submittable": 1, - "modified": "2015-06-15 15:38:08.543029", + "modified": "2015-06-16 16:45:06.618286", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice", diff --git a/erpnext/patches/v5_0/index_on_account_and_gl_entry.py b/erpnext/patches/v5_0/index_on_account_and_gl_entry.py index b03b27a7e7..16e43d64a0 100644 --- a/erpnext/patches/v5_0/index_on_account_and_gl_entry.py +++ b/erpnext/patches/v5_0/index_on_account_and_gl_entry.py @@ -5,18 +5,26 @@ import frappe def execute(): index_map = { "Account": ["parent_account", "lft", "rgt"], - "GL Entry": ["posting_date", "account", 'party', "voucher_no"] + "GL Entry": ["posting_date", "account", 'party', "voucher_no"], + "Sales Invoice": ["posting_date", "debit_to", "customer"], + "Purchase Invoice": ["posting_date", "credit_to", "supplier"] } for dt, indexes in index_map.items(): - existing_indexes = [d.Key_name for d in frappe.db.sql("""show index from `tab{0}` + existing_indexes = [(d.Key_name, d.Column_name) for d in frappe.db.sql("""show index from `tab{0}` where Column_name != 'name'""".format(dt), as_dict=1)] - for old in existing_indexes: - if old in ("parent", "group_or_ledger", "is_pl_account", "debit_or_credit", "account_name", "company"): + for old, column in existing_indexes: + if column in ("parent", "group_or_ledger", "is_group", "is_pl_account", "debit_or_credit", + "account_name", "company", "project_name", "voucher_date", "due_date", "bill_no", + "bill_date", "is_opening", "fiscal_year", "outstanding_amount"): frappe.db.sql("alter table `tab{0}` drop index {1}".format(dt, old)) - existing_indexes.remove(old) + + existing_indexes = [(d.Key_name, d.Column_name) for d in frappe.db.sql("""show index from `tab{0}` + where Column_name != 'name'""".format(dt), as_dict=1)] + + existing_indexed_columns = list(set([x[1] for x in existing_indexes])) for new in indexes: - if new not in existing_indexes: + if new not in existing_indexed_columns: frappe.db.sql("alter table `tab{0}` add index ({1})".format(dt, new)) \ No newline at end of file