From 5b73dea9f6bc6dd16ac0acac693abd39f63e97ab Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 20 Nov 2015 15:42:32 +0530 Subject: [PATCH] [fix] Get items in stock reconciliation based on default warehouse or existing bin --- .../stock_reconciliation.py | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 22946b70b9..b0aff019f5 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -249,18 +249,26 @@ class StockReconciliation(StockController): @frappe.whitelist() def get_items(warehouse, posting_date, posting_time): - items = frappe.get_list("Item", fields=["name"], filters= - {"is_stock_item": 1, "has_serial_no": 0, "has_batch_no": 0, "has_variants": 0}) - for item in items: - item.item_code = item.name - item.warehouse = warehouse - item.qty, item.valuation_rate = get_stock_balance(item.name, warehouse, - posting_date, posting_time, with_valuation_rate=True) - item.current_qty = item.qty - item.current_valuation_rate = item.valuation_rate - del item["name"] + items = frappe.get_list("Bin", fields=["item_code"], filters={"warehouse": warehouse}, as_list=1) + + items += frappe.get_list("Item", fields=["name"], filters= {"is_stock_item": 1, "has_serial_no": 0, + "has_batch_no": 0, "has_variants": 0, "default_warehouse": warehouse}, as_list=1) + + res = [] + for item in set(items): + stock_bal = get_stock_balance(item[0], warehouse, posting_date, posting_time, + with_valuation_rate=True) + + res.append({ + "item_code": item[0], + "warehouse": warehouse, + "qty": stock_bal[0], + "valuation_rate": stock_bal[1], + "current_qty": stock_bal[0], + "current_valuation_rate": stock_bal[1] + }) - return items + return res @frappe.whitelist() def get_stock_balance_for(item_code, warehouse, posting_date, posting_time):