Merge pull request #30488 from Havenir/fix-project-list-in-web-view
fix: web form filters for project
This commit is contained in:
commit
207bf85c74
@ -326,21 +326,39 @@ def get_timeline_data(doctype, name):
|
||||
def get_project_list(
|
||||
doctype, txt, filters, limit_start, limit_page_length=20, order_by="modified"
|
||||
):
|
||||
return frappe.db.sql(
|
||||
"""select distinct project.*
|
||||
from tabProject project, `tabProject User` project_user
|
||||
where
|
||||
(project_user.user = %(user)s
|
||||
and project_user.parent = project.name)
|
||||
or project.owner = %(user)s
|
||||
order by project.modified desc
|
||||
limit {0}, {1}
|
||||
""".format(
|
||||
limit_start, limit_page_length
|
||||
),
|
||||
{"user": frappe.session.user},
|
||||
as_dict=True,
|
||||
update={"doctype": "Project"},
|
||||
meta = frappe.get_meta(doctype)
|
||||
if not filters:
|
||||
filters = []
|
||||
|
||||
fields = "distinct *"
|
||||
|
||||
or_filters = []
|
||||
|
||||
if txt:
|
||||
if meta.search_fields:
|
||||
for f in meta.get_search_fields():
|
||||
if f == "name" or meta.get_field(f).fieldtype in (
|
||||
"Data",
|
||||
"Text",
|
||||
"Small Text",
|
||||
"Text Editor",
|
||||
"select",
|
||||
):
|
||||
or_filters.append([doctype, f, "like", "%" + txt + "%"])
|
||||
else:
|
||||
if isinstance(filters, dict):
|
||||
filters["name"] = ("like", "%" + txt + "%")
|
||||
else:
|
||||
filters.append([doctype, "name", "like", "%" + txt + "%"])
|
||||
|
||||
return frappe.get_list(
|
||||
doctype,
|
||||
fields=fields,
|
||||
filters=filters,
|
||||
or_filters=or_filters,
|
||||
limit_start=limit_start,
|
||||
limit_page_length=limit_page_length,
|
||||
order_by=order_by,
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user