From 497bc8b4eae5a144bf632ba2eb35e3bb68a2e9a0 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 28 Nov 2023 00:29:33 +0530 Subject: [PATCH] fix: renamed data_fields to rows --- crm/api/doc.py | 11 ++++++----- crm/fcrm/doctype/crm_deal/crm_deal.py | 13 +++++++++++-- crm/fcrm/doctype/crm_lead/crm_lead.py | 15 +++++++++++++-- .../crm_list_view_settings.json | 8 ++++---- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/crm/api/doc.py b/crm/api/doc.py index b6e7d8d70..0f7ddcf79 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -53,20 +53,21 @@ def get_list_data(doctype: str, filters: dict, order_by: str): columns = [] rows = [] - data_fields = [] - if frappe.db.exists("CRM List View Settings", doctype): list_view_settings = frappe.get_doc("CRM List View Settings", doctype) columns = frappe.parse_json(list_view_settings.columns) - data_fields = frappe.parse_json(list_view_settings.data_fields) + rows = frappe.parse_json(list_view_settings.rows) else: 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 = list.default_list_data().get("rows") - rows = [i['key'] for i in columns] + data_fields + # check if rows has all keys from columns if not add them + for column in columns: + if column.get("key") not in rows: + rows.append(column.get("key")) data = frappe.get_all( doctype, diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.py b/crm/fcrm/doctype/crm_deal/crm_deal.py index 893084206..05280a149 100644 --- a/crm/fcrm/doctype/crm_deal/crm_deal.py +++ b/crm/fcrm/doctype/crm_deal/crm_deal.py @@ -96,8 +96,17 @@ def default_list_data(): 'width': '8rem', }, ] - data_fields = ['name'] - return {'columns': columns, 'data_fields': data_fields} + rows = [ + "name", + "organization", + "annual_revenue", + "status", + "email", + "mobile_no", + "deal_owner", + "modified", + ] + return {'columns': columns, 'rows': rows} @frappe.whitelist() def add_contact(deal, contact): diff --git a/crm/fcrm/doctype/crm_lead/crm_lead.py b/crm/fcrm/doctype/crm_lead/crm_lead.py index 7c88d480a..53cc570ec 100644 --- a/crm/fcrm/doctype/crm_lead/crm_lead.py +++ b/crm/fcrm/doctype/crm_lead/crm_lead.py @@ -175,8 +175,19 @@ def default_list_data(): 'width': '8rem', }, ] - data_fields = ['name', 'first_name', 'image'] - return {'columns': columns, 'data_fields': data_fields} + rows = [ + "name", + "lead_name", + "organization", + "status", + "email", + "mobile_no", + "lead_owner", + "first_name", + "modified", + "image", + ] + return {'columns': columns, 'rows': rows} @frappe.whitelist() def convert_to_deal(lead): diff --git a/crm/fcrm/doctype/crm_list_view_settings/crm_list_view_settings.json b/crm/fcrm/doctype/crm_list_view_settings/crm_list_view_settings.json index 11727649d..5806c815d 100644 --- a/crm/fcrm/doctype/crm_list_view_settings/crm_list_view_settings.json +++ b/crm/fcrm/doctype/crm_list_view_settings/crm_list_view_settings.json @@ -8,7 +8,7 @@ "field_order": [ "user", "columns", - "data_fields" + "rows" ], "fields": [ { @@ -23,14 +23,14 @@ "options": "User" }, { - "fieldname": "data_fields", + "fieldname": "rows", "fieldtype": "Code", - "label": "Data Fields" + "label": "Rows" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-11-27 18:47:23.123396", + "modified": "2023-11-28 00:17:42.675332", "modified_by": "Administrator", "module": "FCRM", "name": "CRM List View Settings",