From cf55c9c6da39c5e0fad8aa7bd7dbaa8337505179 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 14 Nov 2019 18:22:20 +0530 Subject: [PATCH] fix: stock reconciliation shwoing incorrect current serial no and qty --- .../doctype/stock_reconciliation/stock_reconciliation.py | 2 +- erpnext/stock/utils.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 98a8c59483..3683e60fd6 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -456,7 +456,7 @@ def get_qty_rate_for_serial_nos(item_code, warehouse, posting_date, posting_time } serial_nos_list = [serial_no.get("name") - for serial_no in get_available_serial_nos(item_code, warehouse)] + for serial_no in get_available_serial_nos(args)] qty = len(serial_nos_list) serial_nos = '\n'.join(serial_nos_list) diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py index d7629176a5..2c6c95393b 100644 --- a/erpnext/stock/utils.py +++ b/erpnext/stock/utils.py @@ -293,9 +293,11 @@ def update_included_uom_in_report(columns, result, include_uom, conversion_facto row, key, value = data row[key] = value -def get_available_serial_nos(item_code, warehouse): - return frappe.get_all("Serial No", filters = {'item_code': item_code, - 'warehouse': warehouse, 'delivery_document_no': ''}) or [] +def get_available_serial_nos(args): + return frappe.db.sql(""" SELECT name from `tabSerial No` + WHERE item_code = %(item_code)s and warehouse = %(warehouse)s + and timestamp(purchase_date, purchase_time) <= timestamp(%(posting_date)s, %(posting_time)s) + """, args, as_dict=1) def add_additional_uom_columns(columns, result, include_uom, conversion_factors): if not include_uom or not conversion_factors: