diff --git a/crm/api/doc.py b/crm/api/doc.py
index 9a89fbd6..fd5f6172 100644
--- a/crm/api/doc.py
+++ b/crm/api/doc.py
@@ -1,5 +1,6 @@
import frappe
from frappe.model.document import get_controller
+from frappe.model import no_value_fields
from pypika import Criterion
@@ -50,8 +51,11 @@ def get_filterable_fields(doctype: str):
@frappe.whitelist()
def get_list_data(doctype: str, filters: dict, order_by: str):
- columns = []
- rows = []
+ columns = [
+ {"label": "Name", "type": "Data", "key": "name", "width": "16rem"},
+ {"label": "Last Modified", "type": "Datetime", "key": "modified", "width": "8rem"},
+ ]
+ rows = ["name"]
if frappe.db.exists("CRM List View Settings", doctype):
list_view_settings = frappe.get_doc("CRM List View Settings", doctype)
@@ -77,22 +81,30 @@ def get_list_data(doctype: str, filters: dict, order_by: str):
page_length=20,
) or []
- not_allowed_fieldtypes = [
- "Section Break",
- "Column Break",
- "Tab Break",
+ fields = frappe.get_meta(doctype).fields
+ fields = [field for field in fields if field.fieldtype not in no_value_fields]
+ fields = [
+ {
+ "label": field.label,
+ "type": field.fieldtype,
+ "value": field.fieldname,
+ "options": field.options,
+ }
+ for field in fields
+ if field.label and field.fieldname
]
- fields = frappe.get_meta(doctype).fields
- fields = [field for field in fields if field.fieldtype not in not_allowed_fieldtypes]
- fields = [{"label": field.label, "value": field.fieldname} for field in fields if field.label and field.fieldname]
-
std_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'},
+ {"label": "Name", "type": "Data", "value": "name"},
+ {"label": "Created On", "type": "Datetime", "value": "creation"},
+ {"label": "Last Modified", "type": "Datetime", "value": "modified"},
+ {
+ "label": "Modified By",
+ "type": "Link",
+ "value": "modified_by",
+ "options": "User",
+ },
+ {"label": "Owner", "type": "Link", "value": "owner", "options": "User"},
]
for field in std_fields:
diff --git a/crm/fcrm/doctype/crm_call_log/crm_call_log.py b/crm/fcrm/doctype/crm_call_log/crm_call_log.py
index 27549c3b..8e0c1841 100644
--- a/crm/fcrm/doctype/crm_call_log/crm_call_log.py
+++ b/crm/fcrm/doctype/crm_call_log/crm_call_log.py
@@ -6,7 +6,86 @@ from frappe.model.document import Document
class CRMCallLog(Document):
- pass
+ @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 = [
+ {
+ 'label': 'From',
+ 'type': 'Link',
+ 'key': 'caller',
+ 'options': 'User',
+ 'width': '9rem',
+ },
+ {
+ 'label': 'To',
+ 'type': 'Link',
+ 'key': 'receiver',
+ 'options': 'User',
+ 'width': '9rem',
+ },
+ {
+ 'label': 'Type',
+ 'type': 'Select',
+ 'key': 'type',
+ 'width': '9rem',
+ },
+ {
+ 'label': 'Status',
+ 'type': 'Select',
+ 'key': 'status',
+ 'width': '9rem',
+ },
+ {
+ 'label': 'Duration',
+ 'type': 'Duration',
+ 'key': 'duration',
+ 'width': '6rem',
+ },
+ {
+ 'label': 'From (number)',
+ 'type': 'Data',
+ 'key': 'from',
+ 'width': '9rem',
+ },
+ {
+ 'label': 'To (number)',
+ 'type': 'Data',
+ 'key': 'to',
+ 'width': '9rem',
+ },
+ {
+ 'label': 'Created on',
+ 'type': 'Datetime',
+ 'key': 'creation',
+ 'width': '8rem',
+ },
+ ]
+ rows = [
+ "name",
+ "caller",
+ "receiver",
+ "type",
+ "status",
+ "duration",
+ "from",
+ "to",
+ "creation",
+ ]
+ return {'columns': columns, 'rows': rows}
@frappe.whitelist()
def get_call_log(name):
diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.py b/crm/fcrm/doctype/crm_deal/crm_deal.py
index 05280a14..7774eb3c 100644
--- a/crm/fcrm/doctype/crm_deal/crm_deal.py
+++ b/crm/fcrm/doctype/crm_deal/crm_deal.py
@@ -62,36 +62,45 @@ class CRMDeal(Document):
columns = [
{
'label': 'Organization',
+ 'type': 'Link',
'key': 'organization',
+ 'options': 'CRM Organization',
'width': '11rem',
},
{
'label': 'Amount',
+ 'type': 'Currency',
'key': 'annual_revenue',
'width': '9rem',
},
{
'label': 'Status',
+ 'type': 'Select',
'key': 'status',
'width': '10rem',
},
{
'label': 'Email',
+ 'type': 'Data',
'key': 'email',
'width': '12rem',
},
{
'label': 'Mobile no',
+ 'type': 'Data',
'key': 'mobile_no',
'width': '11rem',
},
{
'label': 'Deal owner',
+ 'type': 'Link',
'key': 'deal_owner',
+ 'options': 'User',
'width': '10rem',
},
{
'label': 'Last modified',
+ 'type': 'Datetime',
'key': 'modified',
'width': '8rem',
},
diff --git a/crm/fcrm/doctype/crm_lead/crm_lead.py b/crm/fcrm/doctype/crm_lead/crm_lead.py
index 53cc570e..98c8e4c4 100644
--- a/crm/fcrm/doctype/crm_lead/crm_lead.py
+++ b/crm/fcrm/doctype/crm_lead/crm_lead.py
@@ -141,36 +141,45 @@ class CRMLead(Document):
columns = [
{
'label': 'Name',
+ 'type': 'Data',
'key': 'lead_name',
'width': '12rem',
},
{
'label': 'Organization',
+ 'type': 'Link',
'key': 'organization',
+ 'options': 'CRM Organization',
'width': '10rem',
},
{
'label': 'Status',
+ 'type': 'Select',
'key': 'status',
'width': '8rem',
},
{
'label': 'Email',
+ 'type': 'Data',
'key': 'email',
'width': '12rem',
},
{
'label': 'Mobile no',
+ 'type': 'Data',
'key': 'mobile_no',
'width': '11rem',
},
{
'label': 'Lead owner',
+ 'type': 'Link',
'key': 'lead_owner',
+ 'options': 'User',
'width': '10rem',
},
{
'label': 'Last modified',
+ 'type': 'Datetime',
'key': 'modified',
'width': '8rem',
},
diff --git a/crm/fcrm/doctype/crm_list_view_settings/crm_list_view_settings.py b/crm/fcrm/doctype/crm_list_view_settings/crm_list_view_settings.py
index fe9ff687..ea591728 100644
--- a/crm/fcrm/doctype/crm_list_view_settings/crm_list_view_settings.py
+++ b/crm/fcrm/doctype/crm_list_view_settings/crm_list_view_settings.py
@@ -2,7 +2,7 @@
# For license information, please see license.txt
import json
import frappe
-from frappe.model.document import Document
+from frappe.model.document import Document, get_controller
class CRMListViewSettings(Document):
@@ -11,19 +11,35 @@ class CRMListViewSettings(Document):
@frappe.whitelist()
def update(doctype, columns, rows):
+ default_rows = sync_default_list_rows(doctype)
+
+ if default_rows:
+ rows = rows + default_rows
+
+ rows = remove_duplicates(rows)
+
if not frappe.db.exists("CRM List View Settings", doctype):
# create new CRM List View Settings
doc = frappe.new_doc("CRM List View Settings")
doc.name = doctype
doc.columns = json.dumps(columns)
- doc.rows = json.dumps(remove_duplicates(rows))
+ doc.rows = json.dumps(rows)
doc.insert()
else:
# update existing CRM List View Settings
doc = frappe.get_doc("CRM List View Settings", doctype)
doc.columns = json.dumps(columns)
- doc.rows = json.dumps(remove_duplicates(rows))
+ doc.rows = json.dumps(rows)
doc.save()
def remove_duplicates(l):
- return list(dict.fromkeys(l))
\ No newline at end of file
+ return list(dict.fromkeys(l))
+
+def sync_default_list_rows(doctype):
+ list = get_controller(doctype)
+ rows = []
+
+ if hasattr(list, "default_list_data"):
+ rows = list.default_list_data().get("rows")
+
+ return rows
diff --git a/crm/fcrm/doctype/crm_organization/crm_organization.py b/crm/fcrm/doctype/crm_organization/crm_organization.py
index 5933eabf..1cdae09c 100644
--- a/crm/fcrm/doctype/crm_organization/crm_organization.py
+++ b/crm/fcrm/doctype/crm_organization/crm_organization.py
@@ -6,4 +6,59 @@ from frappe.model.document import Document
class CRMOrganization(Document):
- pass
+ @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 = [
+ {
+ 'label': 'Organization',
+ 'type': 'Data',
+ 'key': 'organization_name',
+ 'width': '16rem',
+ },
+ {
+ 'label': 'Website',
+ 'type': 'Data',
+ 'key': 'website',
+ 'width': '14rem',
+ },
+ {
+ 'label': 'Industry',
+ 'type': 'Link',
+ 'key': 'industry',
+ 'options': 'CRM Industry',
+ 'width': '14rem',
+ },
+ {
+ 'label': 'Annual Revenue',
+ 'type': 'Currency',
+ 'key': 'annual_revenue',
+ 'width': '14rem',
+ },
+ {
+ 'label': 'Last modified',
+ 'type': 'Datetime',
+ 'key': 'modified',
+ 'width': '8rem',
+ },
+ ]
+ rows = [
+ "name",
+ "organization_name",
+ "organization_logo",
+ "website",
+ "industry",
+ "annual_revenue",
+ "modified",
+ ]
+ return {'columns': columns, 'rows': rows}
diff --git a/crm/hooks.py b/crm/hooks.py
index fdaef00f..abfc9d0e 100644
--- a/crm/hooks.py
+++ b/crm/hooks.py
@@ -117,9 +117,9 @@ website_route_rules = [
# ---------------
# Override standard doctype classes
-# override_doctype_class = {
-# "ToDo": "custom_app.overrides.CustomToDo"
-# }
+override_doctype_class = {
+ "Contact": "crm.overrides.contact.CustomContact"
+}
# Document Events
# ---------------
diff --git a/crm/overrides/contact.py b/crm/overrides/contact.py
new file mode 100644
index 00000000..64c2cc8b
--- /dev/null
+++ b/crm/overrides/contact.py
@@ -0,0 +1,63 @@
+# import frappe
+from frappe import _
+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 = [
+ {
+ 'label': 'Name',
+ 'type': 'Data',
+ 'key': 'full_name',
+ 'width': '17rem',
+ },
+ {
+ 'label': 'Email',
+ 'type': 'Data',
+ 'key': 'email_id',
+ 'width': '12rem',
+ },
+ {
+ 'label': 'Phone',
+ 'type': 'Data',
+ 'key': 'mobile_no',
+ 'width': '12rem',
+ },
+ {
+ 'label': 'Organization',
+ 'type': 'Data',
+ 'key': 'company_name',
+ 'width': '12rem',
+ },
+ {
+ 'label': 'Last modified',
+ 'type': 'Datetime',
+ 'key': 'modified',
+ 'width': '8rem',
+ },
+ ]
+ rows = [
+ "name",
+ "full_name",
+ "company_name",
+ "email_id",
+ "mobile_no",
+ "modified",
+ "image",
+ ]
+ return {'columns': columns, 'rows': rows}
diff --git a/frontend/src/components/ListViews/CallLogsListView.vue b/frontend/src/components/ListViews/CallLogsListView.vue
new file mode 100644
index 00000000..4bbf2441
--- /dev/null
+++ b/frontend/src/components/ListViews/CallLogsListView.vue
@@ -0,0 +1,96 @@
+
+