mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-12 23:07:41 +00:00
fix: SQL syntax error in Purchase Receipt query for empty filters (#44636)
fix(po-analysis): handle SQL error due to empty data in IN() clause
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 48b49cdea4)
This commit is contained in:
@@ -103,6 +103,11 @@ def get_received_amount_data(data):
|
|||||||
pr = frappe.qb.DocType("Purchase Receipt")
|
pr = frappe.qb.DocType("Purchase Receipt")
|
||||||
pr_item = frappe.qb.DocType("Purchase Receipt Item")
|
pr_item = frappe.qb.DocType("Purchase Receipt Item")
|
||||||
|
|
||||||
|
po_items = [row.name for row in data]
|
||||||
|
|
||||||
|
if not po_items:
|
||||||
|
return frappe._dict()
|
||||||
|
|
||||||
query = (
|
query = (
|
||||||
frappe.qb.from_(pr)
|
frappe.qb.from_(pr)
|
||||||
.inner_join(pr_item)
|
.inner_join(pr_item)
|
||||||
@@ -111,12 +116,10 @@ def get_received_amount_data(data):
|
|||||||
pr_item.purchase_order_item,
|
pr_item.purchase_order_item,
|
||||||
Sum(pr_item.base_amount).as_("received_qty_amount"),
|
Sum(pr_item.base_amount).as_("received_qty_amount"),
|
||||||
)
|
)
|
||||||
.where((pr_item.parent == pr.name) & (pr.docstatus == 1))
|
.where((pr.docstatus == 1) & (pr_item.purchase_order_item.isin(po_items)))
|
||||||
.groupby(pr_item.purchase_order_item)
|
.groupby(pr_item.purchase_order_item)
|
||||||
)
|
)
|
||||||
|
|
||||||
query = query.where(pr_item.purchase_order_item.isin([row.name for row in data]))
|
|
||||||
|
|
||||||
data = query.run()
|
data = query.run()
|
||||||
|
|
||||||
if not data:
|
if not data:
|
||||||
|
|||||||
Reference in New Issue
Block a user