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 fe9ff6872..ea5917282 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