Merge pull request #25897 from anupamvs/stock-reconciliation

fix: featching serialized items
This commit is contained in:
rohitwaghchaure 2021-05-31 20:00:26 +05:30 committed by GitHub
commit 6463cbd15e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -477,19 +477,19 @@ class StockReconciliation(StockController):
def get_items(warehouse, posting_date, posting_time, company):
lft, rgt = frappe.db.get_value("Warehouse", warehouse, ["lft", "rgt"])
items = frappe.db.sql("""
select i.name, i.item_name, bin.warehouse
select i.name, i.item_name, bin.warehouse, i.has_serial_no
from tabBin bin, tabItem i
where i.name=bin.item_code and i.disabled=0 and i.is_stock_item = 1
and i.has_variants = 0 and i.has_serial_no = 0 and i.has_batch_no = 0
and i.has_variants = 0 and i.has_batch_no = 0
and exists(select name from `tabWarehouse` where lft >= %s and rgt <= %s and name=bin.warehouse)
""", (lft, rgt))
items += frappe.db.sql("""
select i.name, i.item_name, id.default_warehouse
select i.name, i.item_name, id.default_warehouse, i.has_serial_no
from tabItem i, `tabItem Default` id
where i.name = id.parent
and exists(select name from `tabWarehouse` where lft >= %s and rgt <= %s and name=id.default_warehouse)
and i.is_stock_item = 1 and i.has_serial_no = 0 and i.has_batch_no = 0
and i.is_stock_item = 1 and i.has_batch_no = 0
and i.has_variants = 0 and i.disabled = 0 and id.company=%s
group by i.name
""", (lft, rgt, company))
@ -497,7 +497,7 @@ def get_items(warehouse, posting_date, posting_time, company):
res = []
for d in set(items):
stock_bal = get_stock_balance(d[0], d[2], posting_date, posting_time,
with_valuation_rate=True)
with_valuation_rate=True , with_serial_no=cint(d[3]))
if frappe.db.get_value("Item", d[0], "disabled") == 0:
res.append({
@ -507,7 +507,9 @@ def get_items(warehouse, posting_date, posting_time, company):
"item_name": d[1],
"valuation_rate": stock_bal[1],
"current_qty": stock_bal[0],
"current_valuation_rate": stock_bal[1]
"current_valuation_rate": stock_bal[1],
"current_serial_no": stock_bal[2] if cint(d[3]) else '',
"serial_no": stock_bal[2] if cint(d[3]) else ''
})
return res