repost stock for product bundle materials
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index ca6e137..75c1dff 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -181,6 +181,6 @@
erpnext.patches.v5_1.default_bom
execute:frappe.delete_doc("DocType", "Party Type")
execute:frappe.delete_doc("Module Def", "Contacts")
-erpnext.patches.v5_4.fix_reserved_qty_and_sle_for_packed_items
+erpnext.patches.v5_4.fix_reserved_qty_and_sle_for_packed_items # 30-07-2015
execute:frappe.reload_doctype("Leave Type")
-execute:frappe.db.sql("update `tabLeave Type` set include_holiday=1")
+execute:frappe.db.sql("update `tabLeave Type` set include_holiday=0")
\ No newline at end of file
diff --git a/erpnext/patches/v5_4/fix_reserved_qty_and_sle_for_packed_items.py b/erpnext/patches/v5_4/fix_reserved_qty_and_sle_for_packed_items.py
index 0d46d99..f1632ab 100644
--- a/erpnext/patches/v5_4/fix_reserved_qty_and_sle_for_packed_items.py
+++ b/erpnext/patches/v5_4/fix_reserved_qty_and_sle_for_packed_items.py
@@ -10,15 +10,19 @@
where docstatus = 2 and ifnull(update_stock, 0) = 1""")
if cancelled_invoices:
+ repost_for = frappe.db.sql("""select distinct item_code, warehouse from `tabStock Ledger Entry`
+ where voucher_type = 'Sales Invoice' and voucher_no in (%s)"""
+ % (', '.join(['%s']*len(cancelled_invoices))), tuple(cancelled_invoices))
+
frappe.db.sql("""delete from `tabStock Ledger Entry`
where voucher_type = 'Sales Invoice' and voucher_no in (%s)"""
% (', '.join(['%s']*len(cancelled_invoices))), tuple(cancelled_invoices))
- for item_code, warehouse in frappe.db.sql("select item_code, warehouse from tabBin where ifnull(reserved_qty, 0) < 0"):
-
- repost_actual_qty(item_code, warehouse)
-
- update_bin_qty(item_code, warehouse, {
- "reserved_qty": get_reserved_qty(item_code, warehouse)
- })
-
\ No newline at end of file
+ for item_code, warehouse in repost_for:
+ repost_actual_qty(item_code, warehouse)
+
+ for item_code, warehouse in frappe.db.sql("""select distinct item_code, warehouse
+ from `tabPacked Item` where parenttype = 'Sales Invoice' and docstatus = 1"""):
+ update_bin_qty(item_code, warehouse, {
+ "reserved_qty": get_reserved_qty(item_code, warehouse)
+ })
\ No newline at end of file