[fix] add index on so_detail in Delivery Note Item
This commit is contained in:
parent
574415b59b
commit
4096603656
@ -6,16 +6,18 @@ import frappe
|
|||||||
from erpnext.stock.stock_balance import update_bin_qty, get_reserved_qty
|
from erpnext.stock.stock_balance import update_bin_qty, get_reserved_qty
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
|
frappe.reload_doctype("Sales Order Item")
|
||||||
|
|
||||||
repost_for = frappe.db.sql("""
|
repost_for = frappe.db.sql("""
|
||||||
select
|
select
|
||||||
distinct item_code, warehouse
|
distinct item_code, warehouse
|
||||||
from
|
from
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
select distinct item_code, warehouse
|
select distinct item_code, warehouse
|
||||||
from `tabSales Order Item` where docstatus=1
|
from `tabSales Order Item` where docstatus=1
|
||||||
) UNION (
|
) UNION (
|
||||||
select distinct item_code, warehouse
|
select distinct item_code, warehouse
|
||||||
from `tabPacked Item` where docstatus=1 and parenttype='Sales Order'
|
from `tabPacked Item` where docstatus=1 and parenttype='Sales Order'
|
||||||
)
|
)
|
||||||
) so_item
|
) so_item
|
||||||
@ -27,9 +29,9 @@ def execute():
|
|||||||
update_bin_qty(item_code, warehouse, {
|
update_bin_qty(item_code, warehouse, {
|
||||||
"reserved_qty": get_reserved_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(
|
where exists(
|
||||||
select name from tabItem where name=tabBin.item_code and ifnull(is_stock_item, 0) = 0
|
select name from tabItem where name=tabBin.item_code and ifnull(is_stock_item, 0) = 0
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user