mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 19:59:12 +00:00
[fix][patch] Reserved Qty logic fixed and reposted for existing items
This commit is contained in:
@@ -6,7 +6,22 @@ import frappe
|
||||
from erpnext.utilities.repost_stock import update_bin_qty, get_reserved_qty
|
||||
|
||||
def execute():
|
||||
for item_code, warehouse in frappe.db.sql("select item_code, warehouse from tabBin where ifnull(reserved_qty, 0) < 0"):
|
||||
update_bin_qty(item_code, warehouse, {
|
||||
"reserved_qty": get_reserved_qty(item_code, warehouse)
|
||||
})
|
||||
repost_for = frappe.db.sql("""
|
||||
select
|
||||
distinct item_code, warehouse
|
||||
from
|
||||
(
|
||||
(
|
||||
select distinct item_code, warehouse
|
||||
from `tabSales Order Item` where docstatus=1
|
||||
) UNION (
|
||||
select distinct item_code, warehouse
|
||||
from `tabPacked Item` where docstatus=1 and parenttype='Sales Order'
|
||||
)
|
||||
) items
|
||||
""")
|
||||
|
||||
for item_code, warehouse in repost_for:
|
||||
update_bin_qty(item_code, warehouse, {
|
||||
"reserved_qty": get_reserved_qty(item_code, warehouse)
|
||||
})
|
||||
Reference in New Issue
Block a user