fix: created api to get sort options for any doctype

This commit is contained in:
Shariq Ansari 2023-08-09 19:47:43 +05:30
parent 36b10bffae
commit c0335aed45
2 changed files with 27 additions and 0 deletions

View File

@ -44,3 +44,18 @@ class CRMLead(Document):
if self.is_new() or not self.image:
self.image = has_gravatar(self.email)
@staticmethod
def sort_options():
return [
{ "label": 'Created', "value": 'creation' },
{ "label": 'Modified', "value": 'modified' },
{ "label": 'Status', "value": 'status' },
{ "label": 'Lead owner', "value": 'lead_owner' },
{ "label": 'Organization', "value": 'organization_name' },
{ "label": 'Name', "value": 'lead_name' },
{ "label": 'First Name', "value": 'first_name' },
{ "label": 'Last Name', "value": 'last_name' },
{ "label": 'Email', "value": 'email' },
{ "label": 'Mobile no', "value": 'mobile_no' },
]

12
crm/extends/doc.py Normal file
View File

@ -0,0 +1,12 @@
import frappe
from frappe.model.document import get_controller
@frappe.whitelist()
def sort_options(doctype: str):
c = get_controller(doctype)
if not hasattr(c, "sort_options"):
return []
return c.sort_options()