diff --git a/crm/api/doc.py b/crm/api/doc.py
index dd0c7cc9..6b012bdc 100644
--- a/crm/api/doc.py
+++ b/crm/api/doc.py
@@ -12,6 +12,7 @@ def sort_options(doctype: str):
return c.sort_options()
+
@frappe.whitelist()
def get_filterable_fields(doctype: str):
DocField = frappe.qb.DocType("DocField")
@@ -46,6 +47,34 @@ def get_filterable_fields(doctype: str):
res.extend(from_doc_fields)
return res
+
+@frappe.whitelist()
+def get_list_data(doctype: str, filters: dict, order_by: str):
+ columns = []
+ rows = []
+
+ data_fields = []
+
+ list = get_controller(doctype)
+
+ if hasattr(list, "default_list_data"):
+ columns = list.default_list_data().get("columns")
+ data_fields = list.default_list_data().get("data_fields")
+
+ rows = [i['key'] for i in columns]
+ rows = rows + data_fields
+
+ data = frappe.get_all(
+ doctype,
+ fields=rows,
+ filters=filters,
+ order_by=order_by,
+ page_length=20,
+ ) or []
+
+ return {'data': data, 'columns': columns, 'rows': rows}
+
+
@frappe.whitelist()
def get_doctype_fields(doctype):
not_allowed_fieldtypes = [
@@ -87,6 +116,7 @@ def get_doctype_fields(doctype):
return all_fields
+
def get_field_obj(field):
obj = {
"label": field.label,
@@ -107,6 +137,7 @@ def get_field_obj(field):
return obj
+
def get_type(field):
if field.fieldtype == "Data" and field.options == "Phone":
return "phone"
@@ -120,4 +151,4 @@ def get_type(field):
return "textarea"
elif field.read_only:
return "read_only"
- return field.fieldtype.lower()
\ No newline at end of file
+ return field.fieldtype.lower()
diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.py b/crm/fcrm/doctype/crm_deal/crm_deal.py
index c1f34b28..89308420 100644
--- a/crm/fcrm/doctype/crm_deal/crm_deal.py
+++ b/crm/fcrm/doctype/crm_deal/crm_deal.py
@@ -57,6 +57,48 @@ class CRMDeal(Document):
{ "label": 'Mobile no', "value": 'mobile_no' },
]
+ @staticmethod
+ def default_list_data():
+ columns = [
+ {
+ 'label': 'Organization',
+ 'key': 'organization',
+ 'width': '11rem',
+ },
+ {
+ 'label': 'Amount',
+ 'key': 'annual_revenue',
+ 'width': '9rem',
+ },
+ {
+ 'label': 'Status',
+ 'key': 'status',
+ 'width': '10rem',
+ },
+ {
+ 'label': 'Email',
+ 'key': 'email',
+ 'width': '12rem',
+ },
+ {
+ 'label': 'Mobile no',
+ 'key': 'mobile_no',
+ 'width': '11rem',
+ },
+ {
+ 'label': 'Deal owner',
+ 'key': 'deal_owner',
+ 'width': '10rem',
+ },
+ {
+ 'label': 'Last modified',
+ 'key': 'modified',
+ 'width': '8rem',
+ },
+ ]
+ data_fields = ['name']
+ return {'columns': columns, 'data_fields': data_fields}
+
@frappe.whitelist()
def add_contact(deal, contact):
if not frappe.has_permission("CRM Deal", "write", deal):
diff --git a/crm/fcrm/doctype/crm_lead/crm_lead.py b/crm/fcrm/doctype/crm_lead/crm_lead.py
index 6b016b4a..7c88d480 100644
--- a/crm/fcrm/doctype/crm_lead/crm_lead.py
+++ b/crm/fcrm/doctype/crm_lead/crm_lead.py
@@ -136,6 +136,48 @@ class CRMLead(Document):
{ "label": 'Mobile no', "value": 'mobile_no' },
]
+ @staticmethod
+ def default_list_data():
+ columns = [
+ {
+ 'label': 'Name',
+ 'key': 'lead_name',
+ 'width': '12rem',
+ },
+ {
+ 'label': 'Organization',
+ 'key': 'organization',
+ 'width': '10rem',
+ },
+ {
+ 'label': 'Status',
+ 'key': 'status',
+ 'width': '8rem',
+ },
+ {
+ 'label': 'Email',
+ 'key': 'email',
+ 'width': '12rem',
+ },
+ {
+ 'label': 'Mobile no',
+ 'key': 'mobile_no',
+ 'width': '11rem',
+ },
+ {
+ 'label': 'Lead owner',
+ 'key': 'lead_owner',
+ 'width': '10rem',
+ },
+ {
+ 'label': 'Last modified',
+ 'key': 'modified',
+ 'width': '8rem',
+ },
+ ]
+ data_fields = ['name', 'first_name', 'image']
+ return {'columns': columns, 'data_fields': data_fields}
+
@frappe.whitelist()
def convert_to_deal(lead):
if not frappe.has_permission("CRM Lead", "write", lead):
diff --git a/frontend/src/pages/Deals.vue b/frontend/src/pages/Deals.vue
index 3edbc493..ca0b1897 100644
--- a/frontend/src/pages/Deals.vue
+++ b/frontend/src/pages/Deals.vue
@@ -33,7 +33,7 @@
-
+
-
+