From 712fccd87613f366a00a20f4cb3f686ead9bd1f8 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 20 Aug 2015 14:59:25 +0530 Subject: [PATCH 1/2] [fix][patch] Repost reserved qty for stock item --- erpnext/patches/v4_2/repost_reserved_qty.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/erpnext/patches/v4_2/repost_reserved_qty.py b/erpnext/patches/v4_2/repost_reserved_qty.py index f91968c2d4..4479411284 100644 --- a/erpnext/patches/v4_2/repost_reserved_qty.py +++ b/erpnext/patches/v4_2/repost_reserved_qty.py @@ -18,9 +18,11 @@ def execute(): select distinct item_code, warehouse from `tabPacked Item` where docstatus=1 and parenttype='Sales Order' ) - ) items + ) so_item + where + exists(select name from tabItem where name=so_item.item_code and ifnull(is_stock_item, 0)=1) """) - + for item_code, warehouse in repost_for: update_bin_qty(item_code, warehouse, { "reserved_qty": get_reserved_qty(item_code, warehouse) From 24998a6ca73f29c5380d875cf9b8da69b8d1e8f0 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 20 Aug 2015 15:21:42 +0530 Subject: [PATCH 2/2] [fix][patch] Delete Bin for non-stock item --- erpnext/patches/v4_2/repost_reserved_qty.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/erpnext/patches/v4_2/repost_reserved_qty.py b/erpnext/patches/v4_2/repost_reserved_qty.py index 4479411284..a2cd4d8ad6 100644 --- a/erpnext/patches/v4_2/repost_reserved_qty.py +++ b/erpnext/patches/v4_2/repost_reserved_qty.py @@ -26,4 +26,10 @@ def execute(): for item_code, warehouse in repost_for: update_bin_qty(item_code, warehouse, { "reserved_qty": get_reserved_qty(item_code, warehouse) - }) \ No newline at end of file + }) + + frappe.db.sql("""delete from tabBin + where exists( + select name from tabItem where name=tabBin.item_code and ifnull(is_stock_item, 0) = 0 + ) + """) \ No newline at end of file