Files
erpnext/erpnext/projects/utils.py
mergify[bot] 893683a512 fix: user permission on reports (backport #52709) (#52757)
* fix: user permission on reports (#52709)

(cherry picked from commit c6a292f6a9)

# Conflicts:
#	erpnext/accounts/report/purchase_register/purchase_register.py
#	erpnext/accounts/report/sales_register/sales_register.py

* chore: resolve conflict

---------

Co-authored-by: Diptanil Saha <diptanil@frappe.io>
2026-02-17 23:07:41 +05:30

33 lines
1.0 KiB
Python

# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
# For license information, please see license.txt
import frappe
@frappe.whitelist()
@frappe.validate_and_sanitize_search_inputs
def query_task(doctype, txt, searchfield, start, page_len, filters):
from frappe.desk.reportview import build_match_conditions
search_string = "%%%s%%" % txt
order_by_string = "%s%%" % txt
match_conditions = build_match_conditions("Task")
match_conditions = (f"and ({match_conditions})") if match_conditions else ""
return frappe.db.sql(
"""select name, subject from `tabTask`
where (`{}` like {} or `subject` like {}) {}
order by
case when `subject` like {} then 0 else 1 end,
case when `{}` like {} then 0 else 1 end,
`{}`,
subject
limit {} offset {}""".format(
searchfield, "%s", "%s", match_conditions, "%s", searchfield, "%s", searchfield, "%s", "%s"
),
(search_string, search_string, order_by_string, order_by_string, page_len, start),
)