perf: index for item-sh on repost item valuation

Item-WH based reposting requires querying existing similar repost.
Assuming there is only 1 max extra entry with same params just indexing
item-WH is sufficient to speed up the query.
This commit is contained in:
Ankush Menat 2021-11-02 11:08:36 +05:30 committed by Ankush Menat
parent 45dd46be3d
commit a5a8c9104f
2 changed files with 7 additions and 2 deletions

View File

@ -177,7 +177,7 @@
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2021-11-18 02:18:10.524560", "modified": "2021-11-24 02:18:10.524560",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Repost Item Valuation", "name": "Repost Item Valuation",

View File

@ -58,6 +58,11 @@ class RepostItemValuation(Document):
frappe.enqueue(repost, timeout=1800, queue='long', frappe.enqueue(repost, timeout=1800, queue='long',
job_name='repost_sle', now=True, doc=self) job_name='repost_sle', now=True, doc=self)
def on_doctype_update():
frappe.db.add_index("Repost Item Valuation", ["warehouse", "item_code"], "item_warehouse")
def repost(doc): def repost(doc):
try: try:
if not frappe.db.exists("Repost Item Valuation", doc.name): if not frappe.db.exists("Repost Item Valuation", doc.name):