feat: get quick filters meta
This commit is contained in:
parent
69d6491c80
commit
f5881424dc
@ -126,6 +126,30 @@ def get_fields_meta(DocField, doctype, allowed_fieldtypes, restricted_fields):
|
||||
.run(as_dict=True)
|
||||
)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_quick_filters(doctype: str):
|
||||
meta = frappe.get_meta(doctype)
|
||||
fields = [field for field in meta.fields if field.in_standard_filter]
|
||||
quick_filters = [{"label": _("ID"), "name": "name", "type": "Link", "options": doctype}]
|
||||
|
||||
for field in fields:
|
||||
|
||||
if field.fieldtype == "Select":
|
||||
field.options = field.options.split("\n")
|
||||
field.options = [{"label": option, "value": option} for option in field.options]
|
||||
field.options.insert(0, {"label": "", "value": ""})
|
||||
quick_filters.append({
|
||||
"label": _(field.label),
|
||||
"name": field.fieldname,
|
||||
"type": field.fieldtype,
|
||||
"options": field.options,
|
||||
})
|
||||
|
||||
if doctype == "CRM Lead":
|
||||
quick_filters = [filter for filter in quick_filters if filter.get("name") != "converted"]
|
||||
|
||||
return quick_filters
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_list_data(
|
||||
doctype: str,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user