Merge pull request #9900 from frappe/fixes_9899
[fix] #9899
diff --git a/erpnext/stock/report/stock_balance/stock_balance.py b/erpnext/stock/report/stock_balance/stock_balance.py
index 5e373d6..c3e3cc5 100644
--- a/erpnext/stock/report/stock_balance/stock_balance.py
+++ b/erpnext/stock/report/stock_balance/stock_balance.py
@@ -13,11 +13,18 @@
columns = get_columns()
item_map = get_item_details(filters)
+ item_reorder_detail_map = get_item_reorder_details(filters)
iwb_map = get_item_warehouse_map(filters)
data = []
for (company, item, warehouse) in sorted(iwb_map):
qty_dict = iwb_map[(company, item, warehouse)]
+ item_reorder_level = 0
+ item_reorder_qty = 0
+ if item + warehouse in item_reorder_detail_map:
+ item_reorder_level = item_reorder_detail_map[item + warehouse]["warehouse_reorder_level"]
+ item_reorder_qty = item_reorder_detail_map[item + warehouse]["warehouse_reorder_qty"]
+
data.append([item, item_map[item]["item_name"],
item_map[item]["item_group"],
item_map[item]["brand"],
@@ -27,6 +34,8 @@
qty_dict.in_val, qty_dict.out_qty,
qty_dict.out_val, qty_dict.bal_qty,
qty_dict.bal_val, qty_dict.val_rate,
+ item_reorder_level,
+ item_reorder_qty,
company
])
@@ -52,6 +61,8 @@
_("Balance Qty")+":Float:100",
_("Balance Value")+":Float:100",
_("Valuation Rate")+":Float:90",
+ _("Reorder Level")+":Float:80",
+ _("Reorder Qty")+":Float:80",
_("Company")+":Link/Company:100"
]
@@ -180,7 +191,19 @@
items = frappe.db.sql("""select name, item_name, stock_uom, item_group, brand, description
from tabItem {condition}""".format(condition=condition), value, as_dict=1)
- return dict((d.name, d) for d in items)
+ return dict((d.name , d) for d in items)
+
+def get_item_reorder_details(filters):
+ condition = ''
+ value = ()
+ if filters.get("item_code"):
+ condition = "where parent=%s"
+ value = (filters.get("item_code"),)
+
+ item_reorder_details = frappe.db.sql("""select parent,warehouse,warehouse_reorder_qty,warehouse_reorder_level
+ from `tabItem Reorder` {condition}""".format(condition=condition), value, as_dict=1)
+
+ return dict((d.parent + d.warehouse, d) for d in item_reorder_details)
def validate_filters(filters):
if not (filters.get("item_code") or filters.get("warehouse")):