diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py index 023827c4347..3b9fe7b97cd 100644 --- a/erpnext/stock/doctype/batch/batch.py +++ b/erpnext/stock/doctype/batch/batch.py @@ -6,12 +6,8 @@ import frappe from frappe import _ from frappe.model.document import Document from frappe.model.naming import make_autoname, revert_series_if_last -<<<<<<< HEAD -from frappe.utils import cint, flt, get_link_to_form, nowtime -======= from frappe.query_builder.functions import CurDate, Sum, Timestamp -from frappe.utils import cint, flt, get_link_to_form ->>>>>>> 517b5f8567 (refactor: rewrite `batch.py` queries in `QB`) +from frappe.utils import cint, flt, get_link_to_form, nowtime from frappe.utils.data import add_days from frappe.utils.jinja import render_template @@ -185,26 +181,18 @@ def get_batch_qty( out = 0 if batch_no and warehouse: -<<<<<<< HEAD - cond = "" - - if posting_date: - if posting_time is None: - posting_time = nowtime() - - cond = " and timestamp(posting_date, posting_time) <= timestamp('{0}', '{1}')".format( - posting_date, posting_time -======= query = ( frappe.qb.from_(sle) .select(Sum(sle.actual_qty)) .where((sle.is_cancelled == 0) & (sle.warehouse == warehouse) & (sle.batch_no == batch_no)) ) - if posting_date and posting_time: + if posting_date: + if posting_time is None: + posting_time = nowtime() + query = query.where( Timestamp(sle.posting_date, sle.posting_time) <= Timestamp(posting_date, posting_time) ->>>>>>> 517b5f8567 (refactor: rewrite `batch.py` queries in `QB`) ) out = query.run(as_list=True)[0][0] or 0