diff --git a/erpnext/patches.txt b/erpnext/patches.txt index d75a99c3f0..d9a6b649f1 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -87,3 +87,4 @@ execute:frappe.delete_doc("DocType", "Purchase Request") execute:frappe.delete_doc("DocType", "Purchase Request Item") erpnext.patches.v4_2.recalculate_bom_cost erpnext.patches.v4_2.fix_gl_entries_for_stock_transactions +erpnext.patches.v4_2.update_requested_and_ordered_qty diff --git a/erpnext/patches/v4_2/update_requested_and_ordered_qty.py b/erpnext/patches/v4_2/update_requested_and_ordered_qty.py new file mode 100644 index 0000000000..e44133e6a2 --- /dev/null +++ b/erpnext/patches/v4_2/update_requested_and_ordered_qty.py @@ -0,0 +1,24 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + from erpnext.utilities.repost_stock import update_bin_qty, get_indented_qty, get_ordered_qty + + count=0 + for item_code, warehouse in frappe.db.sql("""select distinct item_code, warehouse from + (select item_code, warehouse from tabBin + union + select item_code, warehouse from `tabStock Ledger Entry`) a"""): + try: + count += 1 + update_bin_qty(item_code, warehouse, { + "indented_qty": get_indented_qty(item_code, warehouse), + "ordered_qty": get_ordered_qty(item_code, warehouse) + }) + if count / 200 == 0: + frappe.db.commit() + except: + frappe.db.rollback()