1
0
forked from test/crm

fix: allow all valid fields in sort by dropdown

This commit is contained in:
Shariq Ansari 2024-01-25 21:36:34 +05:30
parent 38cea32ba7
commit a751b2d3e9
6 changed files with 21 additions and 69 deletions

View File

@ -8,12 +8,29 @@ from crm.api.views import get_views
@frappe.whitelist()
def sort_options(doctype: str):
c = get_controller(doctype)
fields = frappe.get_meta(doctype).fields
fields = [field for field in fields if field.fieldtype not in no_value_fields]
fields = [
{
"label": field.label,
"value": field.fieldname,
}
for field in fields
if field.label and field.fieldname
]
if not hasattr(c, "sort_options"):
return []
standard_fields = [
{"label": "Name", "value": "name"},
{"label": "Created On", "value": "creation"},
{"label": "Last Modified", "value": "modified"},
{"label": "Modified By", "value": "modified_by"},
{"label": "Owner", "value": "owner"},
]
return c.sort_options()
for field in standard_fields:
fields.append(field)
return fields
@frappe.whitelist()

View File

@ -6,20 +6,6 @@ from frappe.model.document import Document
class CRMCallLog(Document):
@staticmethod
def sort_options():
return [
{ "label": 'Created', "value": 'creation' },
{ "label": 'Modified', "value": 'modified' },
{ "label": 'Status', "value": 'status' },
{ "label": 'Type', "value": 'type' },
{ "label": 'Duration', "value": 'duration' },
{ "label": 'From', "value": 'from' },
{ "label": 'To', "value": 'to' },
{ "label": 'Caller', "value": 'caller' },
{ "label": 'Receiver', "value": 'receiver' },
]
@staticmethod
def default_list_data():
columns = [

View File

@ -114,18 +114,6 @@ class CRMDeal(Document):
if sla:
sla.apply(self)
@staticmethod
def sort_options():
return [
{ "label": 'Created', "value": 'creation' },
{ "label": 'Modified', "value": 'modified' },
{ "label": 'Status', "value": 'status' },
{ "label": 'Deal owner', "value": 'deal_owner' },
{ "label": 'Organization', "value": 'organization' },
{ "label": 'Email', "value": 'email' },
{ "label": 'Mobile no', "value": 'mobile_no' },
]
@staticmethod
def default_list_data():
columns = [

View File

@ -206,21 +206,6 @@ class CRMLead(Document):
if sla:
sla.apply(self)
@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' },
{ "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' },
]
@staticmethod
def get_non_filterable_fields():
return ["converted"]

View File

@ -26,17 +26,6 @@ class CRMOrganization(Document):
if self.has_value_changed("annual_revenue"):
frappe.db.set_value("CRM Deal", deal.name, "annual_revenue", self.annual_revenue)
@staticmethod
def sort_options():
return [
{ "label": 'Created', "value": 'creation' },
{ "label": 'Modified', "value": 'modified' },
{ "label": 'Name', "value": 'name' },
{ "label": 'Website', "value": 'website' },
{ "label": 'Amount', "value": 'annual_revenue' },
{ "label": 'Industry', "value": 'industry' },
]
@staticmethod
def default_list_data():
columns = [

View File

@ -4,19 +4,6 @@ from frappe.contacts.doctype.contact.contact import Contact
class CustomContact(Contact):
@staticmethod
def sort_options():
return [
{ "label": 'Created', "value": 'creation' },
{ "label": 'Modified', "value": 'modified' },
{ "label": 'Organization', "value": 'company_name' },
{ "label": 'Full Name', "value": 'full_name' },
{ "label": 'First Name', "value": 'first_name' },
{ "label": 'Last Name', "value": 'last_name' },
{ "label": 'Email', "value": 'email' },
{ "label": 'Mobile no', "value": 'mobile_no' },
]
@staticmethod
def default_list_data():
columns = [