Skip to content

Commit

Permalink
Merge pull request #34926 from frappe/mergify/bp/version-14-hotfix/pr…
Browse files Browse the repository at this point in the history
…-34895

fix: use `CombineDatetime` instead of `Timestamp` in QB queries (backport #34895)
  • Loading branch information
s-aga-r committed Apr 20, 2023
2 parents 1ab83c5 + a2c25ed commit c11b98f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions erpnext/stock/doctype/batch/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from frappe import _
from frappe.model.document import Document
from frappe.model.naming import make_autoname, revert_series_if_last
from frappe.query_builder.functions import CurDate, Sum, Timestamp
from frappe.query_builder.functions import CombineDatetime, CurDate, Sum
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
Expand Down Expand Up @@ -192,7 +192,8 @@ def get_batch_qty(
posting_time = nowtime()

query = query.where(
Timestamp(sle.posting_date, sle.posting_time) <= Timestamp(posting_date, posting_time)
CombineDatetime(sle.posting_date, sle.posting_time)
<= CombineDatetime(posting_date, posting_time)
)

out = query.run(as_list=True)[0][0] or 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import frappe
from frappe import _
from frappe.query_builder import Field
from frappe.query_builder.functions import Min, Timestamp
from frappe.query_builder.functions import CombineDatetime, Min
from frappe.utils import add_days, getdate, today

import erpnext
Expand Down Expand Up @@ -75,7 +75,7 @@ def get_data(report_filters):
& (sle.company == report_filters.company)
& (sle.is_cancelled == 0)
)
.orderby(Timestamp(sle.posting_date, sle.posting_time), sle.creation)
.orderby(CombineDatetime(sle.posting_date, sle.posting_time), sle.creation)
).run(as_dict=True)

for d in data:
Expand Down

0 comments on commit c11b98f

Please sign in to comment.