fix(bin): update requested qty in bin (#18297)
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index a293785..f5666df 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -505,6 +505,7 @@
erpnext.patches.v10_0.set_student_party_type
erpnext.patches.v10_0.update_project_in_sle
erpnext.patches.v10_0.fix_reserved_qty_for_sub_contract
+erpnext.patches.v10_0.repost_requested_qty_for_non_stock_uom_items
erpnext.patches.v11_0.merge_land_unit_with_location
erpnext.patches.v11_0.add_index_on_nestedset_doctypes
erpnext.patches.v11_0.remove_modules_setup_page
@@ -619,4 +620,4 @@
execute:frappe.delete_doc("DocType", "Project Task")
erpnext.patches.v11_1.update_default_supplier_in_item_defaults
erpnext.patches.v12_0.update_due_date_in_gle
-erpnext.patches.v12_0.add_default_buying_selling_terms_in_company
+erpnext.patches.v12_0.add_default_buying_selling_terms_in_company
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/repost_requested_qty_for_non_stock_uom_items.py b/erpnext/patches/v10_0/repost_requested_qty_for_non_stock_uom_items.py
new file mode 100644
index 0000000..4fe4e97
--- /dev/null
+++ b/erpnext/patches/v10_0/repost_requested_qty_for_non_stock_uom_items.py
@@ -0,0 +1,21 @@
+# Copyright (c) 2019, 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.stock.stock_balance import update_bin_qty, get_indented_qty
+
+ count=0
+ for item_code, warehouse in frappe.db.sql("""select distinct item_code, warehouse
+ from `tabMaterial Request Item` where docstatus = 1 and stock_uom<>uom"""):
+ try:
+ count += 1
+ update_bin_qty(item_code, warehouse, {
+ "indented_qty": get_indented_qty(item_code, warehouse),
+ })
+ if count % 200 == 0:
+ frappe.db.commit()
+ except:
+ frappe.db.rollback()
diff --git a/erpnext/stock/stock_balance.py b/erpnext/stock/stock_balance.py
index 4d07a0e..d68f979 100644
--- a/erpnext/stock/stock_balance.py
+++ b/erpnext/stock/stock_balance.py
@@ -110,7 +110,7 @@
return flt(reserved_qty[0][0]) if reserved_qty else 0
def get_indented_qty(item_code, warehouse):
- indented_qty = frappe.db.sql("""select sum(mr_item.qty - mr_item.ordered_qty)
+ indented_qty = frappe.db.sql("""select sum((mr_item.qty - mr_item.ordered_qty) * mr_item.conversion_factor)
from `tabMaterial Request Item` mr_item, `tabMaterial Request` mr
where mr_item.item_code=%s and mr_item.warehouse=%s
and mr_item.qty > mr_item.ordered_qty and mr_item.parent=mr.name