From 326d07e5b600fa8a5d20204057e09bc628993486 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 7 Jun 2024 19:49:30 +0530 Subject: [PATCH 1/8] fix: added CRM Fields Layout doctype --- .../doctype/crm_fields_layout/__init__.py | 0 .../crm_fields_layout/crm_fields_layout.js | 8 ++ .../crm_fields_layout/crm_fields_layout.json | 73 +++++++++++++++++++ .../crm_fields_layout/crm_fields_layout.py | 9 +++ .../test_crm_fields_layout.py | 9 +++ 5 files changed, 99 insertions(+) create mode 100644 crm/fcrm/doctype/crm_fields_layout/__init__.py create mode 100644 crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.js create mode 100644 crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.json create mode 100644 crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py create mode 100644 crm/fcrm/doctype/crm_fields_layout/test_crm_fields_layout.py diff --git a/crm/fcrm/doctype/crm_fields_layout/__init__.py b/crm/fcrm/doctype/crm_fields_layout/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.js b/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.js new file mode 100644 index 00000000..6a3abeb8 --- /dev/null +++ b/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.js @@ -0,0 +1,8 @@ +// Copyright (c) 2024, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +// frappe.ui.form.on("CRM Fields Layout", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.json b/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.json new file mode 100644 index 00000000..c780557a --- /dev/null +++ b/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.json @@ -0,0 +1,73 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "format:{dt}-{type}", + "creation": "2024-06-07 16:42:05.495324", + "doctype": "DocType", + "engine": "InnoDB", + "field_order": [ + "dt", + "column_break_post", + "type", + "section_break_ttpm", + "layout" + ], + "fields": [ + { + "fieldname": "dt", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Document Type", + "options": "DocType", + "unique": 1 + }, + { + "fieldname": "type", + "fieldtype": "Select", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Type", + "options": "Quick Entry\nSide Panel" + }, + { + "fieldname": "section_break_ttpm", + "fieldtype": "Section Break" + }, + { + "fieldname": "layout", + "fieldtype": "Code", + "label": "Layout", + "options": "JS" + }, + { + "fieldname": "column_break_post", + "fieldtype": "Column Break" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2024-06-07 17:01:20.250697", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Fields Layout", + "naming_rule": "Expression", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "creation", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py b/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py new file mode 100644 index 00000000..36d8bb72 --- /dev/null +++ b/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py @@ -0,0 +1,9 @@ +# Copyright (c) 2024, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + + +class CRMFieldsLayout(Document): + pass diff --git a/crm/fcrm/doctype/crm_fields_layout/test_crm_fields_layout.py b/crm/fcrm/doctype/crm_fields_layout/test_crm_fields_layout.py new file mode 100644 index 00000000..bdc71c0a --- /dev/null +++ b/crm/fcrm/doctype/crm_fields_layout/test_crm_fields_layout.py @@ -0,0 +1,9 @@ +# Copyright (c) 2024, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt + +# import frappe +from frappe.tests.utils import FrappeTestCase + + +class TestCRMFieldsLayout(FrappeTestCase): + pass From ec6de13451065a862cb80ee8258f1aa33c6f946a Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 7 Jun 2024 19:53:46 +0530 Subject: [PATCH 2/8] feat: get quick entry fields api --- crm/api/doc.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/crm/api/doc.py b/crm/api/doc.py index fae49446..f8e20b85 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -1,4 +1,5 @@ import frappe +import json from frappe import _ from frappe.model.document import get_controller from frappe.model import no_value_fields @@ -156,6 +157,43 @@ def get_group_by_fields(doctype: str): return fields +@frappe.whitelist() +def get_quick_entry_fields(doctype: str): + sections = [] + if frappe.db.exists("CRM Fields Layout", {"dt": doctype, "type": "Quick Entry"}): + layout = frappe.get_doc("CRM Fields Layout", {"dt": doctype, "type": "Quick Entry"}) + else: + return [] + + if layout.layout: + sections = json.loads(layout.layout) + + allowed_fields = [] + for section in sections: + allowed_fields.extend(section.get("fields")) + + fields = frappe.get_meta(doctype).fields + fields = [field for field in fields if field.fieldname in allowed_fields] + + for section in sections: + for field in section.get("fields"): + field = next((f for f in fields if f.fieldname == field), None) + if field: + if field.fieldtype == "Select": + field.options = field.options.split("\n") + field.options = [{"label": _(option), "value": option} for option in field.options] + field.options.insert(0, {"label": "", "value": ""}) + field = { + "label": _(field.label), + "name": field.fieldname, + "type": field.fieldtype, + "options": field.options, + "mandatory": field.reqd, + } + section["fields"][section.get("fields").index(field["name"])] = field + + return sections or [] + def get_fields_meta(DocField, doctype, allowed_fieldtypes, restricted_fields): parent = "parent" if DocField._table_name == "tabDocField" else "dt" return ( From cf632969ac20242aa4da2cfcbcb4e327bac36cca Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 7 Jun 2024 19:54:29 +0530 Subject: [PATCH 3/8] fix: updated Fields component --- frontend/src/components/Fields.vue | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/Fields.vue b/frontend/src/components/Fields.vue index 84a59179..b93c2357 100644 --- a/frontend/src/components/Fields.vue +++ b/frontend/src/components/Fields.vue @@ -2,7 +2,7 @@
@@ -20,34 +20,34 @@ *
-
+