Added indexes for lft, rgt on nestedset doctypes (#13420)
This commit is contained in:
parent
5d71609f0b
commit
c825e914d1
@ -274,3 +274,7 @@ def get_name_with_number(new_account, account_number):
|
|||||||
if account_number and not new_account[0].isdigit():
|
if account_number and not new_account[0].isdigit():
|
||||||
new_account = account_number + " - " + new_account
|
new_account = account_number + " - " + new_account
|
||||||
return new_account
|
return new_account
|
||||||
|
|
||||||
|
|
||||||
|
def on_doctype_update():
|
||||||
|
frappe.db.add_index("Account", ["lft", "rgt"])
|
@ -64,3 +64,6 @@ class CostCenter(NestedSet):
|
|||||||
if not merge:
|
if not merge:
|
||||||
frappe.db.set_value("Cost Center", newdn, "cost_center_name",
|
frappe.db.set_value("Cost Center", newdn, "cost_center_name",
|
||||||
" - ".join(newdn.split(" - ")[:-1]))
|
" - ".join(newdn.split(" - ")[:-1]))
|
||||||
|
|
||||||
|
def on_doctype_update():
|
||||||
|
frappe.db.add_index("Cost Center", ["lft", "rgt"])
|
@ -178,3 +178,6 @@ def get_children(doctype, parent, is_root=False):
|
|||||||
# return nodes
|
# return nodes
|
||||||
return land_units
|
return land_units
|
||||||
|
|
||||||
|
|
||||||
|
def on_doctype_update():
|
||||||
|
frappe.db.add_index("Land Unit", ["lft", "rgt"])
|
@ -330,3 +330,7 @@ def get_children(doctype, parent=None, company=None, is_root=False, is_tree=Fals
|
|||||||
|
|
||||||
# return employee
|
# return employee
|
||||||
return employee
|
return employee
|
||||||
|
|
||||||
|
|
||||||
|
def on_doctype_update():
|
||||||
|
frappe.db.add_index("Employee", ["lft", "rgt"])
|
@ -515,3 +515,4 @@ erpnext.patches.v10_0.update_hub_connector_domain
|
|||||||
erpnext.patches.v10_0.set_student_party_type
|
erpnext.patches.v10_0.set_student_party_type
|
||||||
erpnext.patches.v10_0.update_project_in_sle
|
erpnext.patches.v10_0.update_project_in_sle
|
||||||
erpnext.patches.v10_0.fix_reserved_qty_for_sub_contract
|
erpnext.patches.v10_0.fix_reserved_qty_for_sub_contract
|
||||||
|
erpnext.patches.v11_0.add_index_on_nestedset_doctypes
|
8
erpnext/patches/v11_0/add_index_on_nestedset_doctypes.py
Normal file
8
erpnext/patches/v11_0/add_index_on_nestedset_doctypes.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
for dt in ("Account", "Cost Center", "File", "Employee", "Land Unit", "Task", "Customer Group", "Sales Person", "Territory"):
|
||||||
|
frappe.get_doc("DocType", dt).run_module_method("on_doctype_update")
|
@ -236,3 +236,6 @@ def add_multiple_tasks(data, parent):
|
|||||||
new_doc['subject'] = d.get("subject")
|
new_doc['subject'] = d.get("subject")
|
||||||
new_task = frappe.get_doc(new_doc)
|
new_task = frappe.get_doc(new_doc)
|
||||||
new_task.insert()
|
new_task.insert()
|
||||||
|
|
||||||
|
def on_doctype_update():
|
||||||
|
frappe.db.add_index("Task", ["lft", "rgt"])
|
@ -25,3 +25,6 @@ def get_parent_customer_groups(customer_group):
|
|||||||
return frappe.db.sql("""select name from `tabCustomer Group`
|
return frappe.db.sql("""select name from `tabCustomer Group`
|
||||||
where lft <= %s and rgt >= %s
|
where lft <= %s and rgt >= %s
|
||||||
order by lft asc""", (lft, rgt), as_dict=True)
|
order by lft asc""", (lft, rgt), as_dict=True)
|
||||||
|
|
||||||
|
def on_doctype_update():
|
||||||
|
frappe.db.add_index("Customer Group", ["lft", "rgt"])
|
@ -33,3 +33,6 @@ class SalesPerson(NestedSet):
|
|||||||
|
|
||||||
if sales_person and sales_person != self.name:
|
if sales_person and sales_person != self.name:
|
||||||
frappe.throw(_("Another Sales Person {0} exists with the same Employee id").format(sales_person))
|
frappe.throw(_("Another Sales Person {0} exists with the same Employee id").format(sales_person))
|
||||||
|
|
||||||
|
def on_doctype_update():
|
||||||
|
frappe.db.add_index("Sales Person", ["lft", "rgt"])
|
@ -22,3 +22,5 @@ class Territory(NestedSet):
|
|||||||
super(Territory, self).on_update()
|
super(Territory, self).on_update()
|
||||||
self.validate_one_root()
|
self.validate_one_root()
|
||||||
|
|
||||||
|
def on_doctype_update():
|
||||||
|
frappe.db.add_index("Territory", ["lft", "rgt"])
|
Loading…
x
Reference in New Issue
Block a user