Skip to content

Commit

Permalink
fix: mismatch between warehouse tree value and warehouse based stock …
Browse files Browse the repository at this point in the history
…balance report value (#18877)
  • Loading branch information
rohitwaghchaure authored and nabinhait committed Sep 5, 2019
1 parent 67aa7b8 commit f5d2337
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions erpnext/stock/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def get_stock_value_from_bin(warehouse=None, item_code=None):
values = {}
conditions = ""
if warehouse:
conditions += """ and warehouse in (
conditions += """ and `tabBin`.warehouse in (
select w2.name from `tabWarehouse` w1
join `tabWarehouse` w2 on
w1.name = %(warehouse)s
Expand All @@ -25,11 +25,12 @@ def get_stock_value_from_bin(warehouse=None, item_code=None):
values['warehouse'] = warehouse

if item_code:
conditions += " and item_code = %(item_code)s"
conditions += " and `tabBin`.item_code = %(item_code)s"

values['item_code'] = item_code

query = "select sum(stock_value) from `tabBin` where 1 = 1 %s" % conditions
query = """select sum(stock_value) from `tabBin`, `tabItem` where 1 = 1
and `tabItem`.name = `tabBin`.item_code and ifnull(`tabItem`.disabled, 0) = 0 %s""" % conditions

stock_value = frappe.db.sql(query, values)

Expand Down

0 comments on commit f5d2337

Please sign in to comment.