[fix] add index on so_detail in Delivery Note Item

This commit is contained in:
Anand Doshi 2016-01-07 16:47:44 +05:30
parent 574415b59b
commit 4096603656
2 changed files with 1205 additions and 1203 deletions

View File

@ -6,16 +6,18 @@ import frappe
from erpnext.stock.stock_balance import update_bin_qty, get_reserved_qty
def execute():
frappe.reload_doctype("Sales Order Item")
repost_for = frappe.db.sql("""
select
distinct item_code, warehouse
from
select
distinct item_code, warehouse
from
(
(
select distinct item_code, warehouse
select distinct item_code, warehouse
from `tabSales Order Item` where docstatus=1
) UNION (
select distinct item_code, warehouse
select distinct item_code, warehouse
from `tabPacked Item` where docstatus=1 and parenttype='Sales Order'
)
) so_item
@ -27,9 +29,9 @@ def execute():
update_bin_qty(item_code, warehouse, {
"reserved_qty": get_reserved_qty(item_code, warehouse)
})
frappe.db.sql("""delete from tabBin
frappe.db.sql("""delete from tabBin
where exists(
select name from tabItem where name=tabBin.item_code and ifnull(is_stock_item, 0) = 0
)
""")
""")