From 4e4a52d6ac6b02ec590be6c3aac5cb6560d7ed17 Mon Sep 17 00:00:00 2001 From: JoshuaR <36710177+joshuarestivo@users.noreply.github.com> Date: Thu, 26 Sep 2024 19:43:07 +0000 Subject: [PATCH 1/8] Add Z1N custom css --- frontend/src/assets/custom.css | 123 +++++++++++++++++++++++++++++++++ frontend/src/index.css | 1 + 2 files changed, 124 insertions(+) create mode 100644 frontend/src/assets/custom.css diff --git a/frontend/src/assets/custom.css b/frontend/src/assets/custom.css new file mode 100644 index 000000000..ecbe48186 --- /dev/null +++ b/frontend/src/assets/custom.css @@ -0,0 +1,123 @@ +@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap'); +@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap'); + +:root { + --primary: #8b2e9f; + --secondary: #7e368d; + --icon-stroke: #5d3a7c; + --heading-color: #4b0082; + --subheading-color: #5d3a7c; + --text-color: #8b2e9f; + --text-muted: #7e368d; + --control-bg: #f8f5f5; + --disabled-control-bg: #f8f5f5; + --control-bg-on-gray: #f8f5f5; + --disabled-text-color: #7e368d; + --border-color: #e2d6eb; + --table-border-color: #e2d6eb; + --checkbox-gradient: linear-gradient(180deg, #7e368d -124.51%, #7e368d 100%); + --heading-gradient: linear-gradient(to right, #4b0082, #a331b9); + --scroll-bg: #d5b8db; + --scroll-color: #f8f5f5; +} + +h1,h2,h3 { + color: var(--subheading-color) !important; +} + +table { + text-indent: 5px !important; +} + +[type="checkbox"]:checked { + background-color: var(--heading-color) !important; +} + +.feather { + color: var(--subheading-color) !important; +} + +.h-10.w-10 { + color: var(--text-muted) !important; +} + +.feather.feather-plus.feather.feather-plus.shrink-0.h-4.h-4 { + color:#c7d2dd !important; +} + +inline-flex.items-center.justify-center.gap-2.transition-colors.focus:outline-none.text-gray-800.bg-gray-100.hover:bg-gray-200.active:bg-gray-300.focus-visible:ring.focus-visible:ring-gray-400.h-7.text-base.px-2.rounded { + background-color: (--heading-color) !important; +} + +.prose { + color: var(--text-muted) !important; +} + +.svg { + color: var(--subheading-color) !important; + stroke: var(--subheading-color); +} + +.text-base { + color: var(--text-color) !important; +} + +.text-lg { + color: var(--heading-color) !important; + font-family: 'Poppins'; +} + +.text-xl { + color: var(--heading-color) !important; + font-family: 'Poppins'; +} + +.text-2xl { + color: var(--heading-color) !important; + font-family: 'Poppins'; +} + +.text-gray-500 { + color: var(--text-muted) !important; +} + +.text-gray-700 { + color: var(--subheading-color) !important; +} + +.\!text-gray-700.\!bg-gray-100 { + color: var(--text-color) !important; +} + +.text-gray-800 { + color: var(--text-color); +} + +.text-red-600 { + color: rgb(204 41 41 / var(--tw-text-opacity)) !important; +} + +.text-sm { + color: var(--subheading-color) !important; +} + +.text-white { + color: #f3f9ff !important; +background-color: var(--text-muted) !important; +} + +/* Scrollbar */ +*::-webkit-scrollbar { + width: 6px; +} +*::-webkit-scrollbar-track { + background: var(--scroll-bg); +} +*::-webkit-scrollbar-thumb { + background-color: var(--scroll-color); + border-radius: 20px; +} +* { + scrollbar-width: thin; + scrollbar-color: var(--scroll-color) var(--scroll-bg); +} \ No newline at end of file diff --git a/frontend/src/index.css b/frontend/src/index.css index e2fc4dd51..6afc40d43 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -1,5 +1,6 @@ @import './assets/Inter/inter.css'; @import 'frappe-ui/src/style.css'; +@import './assets/custom.css'; @layer components { .prose-f { From de00df70a099aa4ad15f096870fad9bc86ad809e Mon Sep 17 00:00:00 2001 From: JoshuaR <36710177+joshuarestivo@users.noreply.github.com> Date: Sun, 13 Oct 2024 18:13:18 +0000 Subject: [PATCH 2/8] Add CRM Deal Element, CRM Deal Elements (child table), and related fixtures --- crm/fcrm/doctype/crm_deal/crm_deal.json | 21 ++++- crm/fcrm/doctype/crm_deal_element/__init__.py | 0 .../crm_deal_element/crm_deal_element.js | 8 ++ .../crm_deal_element/crm_deal_element.json | 81 +++++++++++++++++++ .../crm_deal_element/crm_deal_element.py | 9 +++ .../crm_deal_element/test_crm_deal_element.py | 9 +++ .../doctype/crm_deal_elements/__init__.py | 0 .../crm_deal_elements/crm_deal_elements.json | 31 +++++++ .../crm_deal_elements/crm_deal_elements.py | 9 +++ crm/fixtures/crm_deal_element.json | 34 ++++++++ crm/hooks.py | 2 + crm/website/__init__.py | 0 12 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 crm/fcrm/doctype/crm_deal_element/__init__.py create mode 100644 crm/fcrm/doctype/crm_deal_element/crm_deal_element.js create mode 100644 crm/fcrm/doctype/crm_deal_element/crm_deal_element.json create mode 100644 crm/fcrm/doctype/crm_deal_element/crm_deal_element.py create mode 100644 crm/fcrm/doctype/crm_deal_element/test_crm_deal_element.py create mode 100644 crm/fcrm/doctype/crm_deal_elements/__init__.py create mode 100644 crm/fcrm/doctype/crm_deal_elements/crm_deal_elements.json create mode 100644 crm/fcrm/doctype/crm_deal_elements/crm_deal_elements.py create mode 100644 crm/fixtures/crm_deal_element.json create mode 100644 crm/website/__init__.py diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.json b/crm/fcrm/doctype/crm_deal/crm_deal.json index 34a22e35a..e3d6f8bbd 100644 --- a/crm/fcrm/doctype/crm_deal/crm_deal.json +++ b/crm/fcrm/doctype/crm_deal/crm_deal.json @@ -7,6 +7,9 @@ "doctype": "DocType", "engine": "InnoDB", "field_order": [ + "tab_6_tab", + "details_section", + "deal_elements", "organization_tab", "naming_series", "organization", @@ -334,11 +337,27 @@ "fieldtype": "Link", "label": "Currency", "options": "Currency" + }, + { + "fieldname": "tab_6_tab", + "fieldtype": "Tab Break", + "label": "Details" + }, + { + "fieldname": "details_section", + "fieldtype": "Section Break", + "label": "Details" + }, + { + "fieldname": "deal_elements", + "fieldtype": "Table MultiSelect", + "label": "Deal Elements", + "options": "CRM Deal Elements" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2024-09-17 18:34:15.873610", + "modified": "2024-10-13 07:25:20.676662", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Deal", diff --git a/crm/fcrm/doctype/crm_deal_element/__init__.py b/crm/fcrm/doctype/crm_deal_element/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/crm/fcrm/doctype/crm_deal_element/crm_deal_element.js b/crm/fcrm/doctype/crm_deal_element/crm_deal_element.js new file mode 100644 index 000000000..41e5c68c7 --- /dev/null +++ b/crm/fcrm/doctype/crm_deal_element/crm_deal_element.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 Deal Element", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/doctype/crm_deal_element/crm_deal_element.json b/crm/fcrm/doctype/crm_deal_element/crm_deal_element.json new file mode 100644 index 000000000..624efebdf --- /dev/null +++ b/crm/fcrm/doctype/crm_deal_element/crm_deal_element.json @@ -0,0 +1,81 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "field:element", + "creation": "2024-10-13 07:26:41.773925", + "doctype": "DocType", + "engine": "InnoDB", + "field_order": [ + "element", + "description" + ], + "fields": [ + { + "allow_in_quick_entry": 1, + "fieldname": "element", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Element", + "unique": 1 + }, + { + "allow_in_quick_entry": 1, + "fieldname": "description", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Description" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2024-10-13 13:04:27.910341", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Deal Element", + "naming_rule": "By fieldname", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "write": 1 + }, + { + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "write": 1 + } + ], + "quick_entry": 1, + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/doctype/crm_deal_element/crm_deal_element.py b/crm/fcrm/doctype/crm_deal_element/crm_deal_element.py new file mode 100644 index 000000000..fbd63c67c --- /dev/null +++ b/crm/fcrm/doctype/crm_deal_element/crm_deal_element.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 CRMDealElement(Document): + pass diff --git a/crm/fcrm/doctype/crm_deal_element/test_crm_deal_element.py b/crm/fcrm/doctype/crm_deal_element/test_crm_deal_element.py new file mode 100644 index 000000000..ba3e36768 --- /dev/null +++ b/crm/fcrm/doctype/crm_deal_element/test_crm_deal_element.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 TestCRMDealElement(FrappeTestCase): + pass diff --git a/crm/fcrm/doctype/crm_deal_elements/__init__.py b/crm/fcrm/doctype/crm_deal_elements/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/crm/fcrm/doctype/crm_deal_elements/crm_deal_elements.json b/crm/fcrm/doctype/crm_deal_elements/crm_deal_elements.json new file mode 100644 index 000000000..d25bb0140 --- /dev/null +++ b/crm/fcrm/doctype/crm_deal_elements/crm_deal_elements.json @@ -0,0 +1,31 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2024-10-13 13:06:22.305044", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "deal_elements" + ], + "fields": [ + { + "fieldname": "deal_elements", + "fieldtype": "Link", + "label": "Deal Elements", + "options": "CRM Deal Element" + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2024-10-13 13:07:29.615600", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Deal Elements", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/doctype/crm_deal_elements/crm_deal_elements.py b/crm/fcrm/doctype/crm_deal_elements/crm_deal_elements.py new file mode 100644 index 000000000..ab34f483c --- /dev/null +++ b/crm/fcrm/doctype/crm_deal_elements/crm_deal_elements.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 CRMDealElements(Document): + pass diff --git a/crm/fixtures/crm_deal_element.json b/crm/fixtures/crm_deal_element.json new file mode 100644 index 000000000..a45072e3e --- /dev/null +++ b/crm/fixtures/crm_deal_element.json @@ -0,0 +1,34 @@ +[ + { + "description": null, + "docstatus": 0, + "doctype": "CRM Deal Element", + "element": "Professional Services", + "modified": "2024-10-13 07:30:07.498734", + "name": "Professional Services" + }, + { + "description": null, + "docstatus": 0, + "doctype": "CRM Deal Element", + "element": "Hardware", + "modified": "2024-10-13 07:30:17.092631", + "name": "Hardware" + }, + { + "description": null, + "docstatus": 0, + "doctype": "CRM Deal Element", + "element": "Software", + "modified": "2024-10-13 07:30:59.080102", + "name": "Software" + }, + { + "description": null, + "docstatus": 0, + "doctype": "CRM Deal Element", + "element": "Support", + "modified": "2024-10-13 07:31:19.032342", + "name": "Support" + } +] \ No newline at end of file diff --git a/crm/hooks.py b/crm/hooks.py index dfc4c9d75..010f682de 100644 --- a/crm/hooks.py +++ b/crm/hooks.py @@ -251,3 +251,5 @@ # auth_hooks = [ # "crm.auth.validate" # ] + +fixtures = ["CRM Deal Element"] diff --git a/crm/website/__init__.py b/crm/website/__init__.py new file mode 100644 index 000000000..e69de29bb From 42abc3a333ae95627d4a85966e58caae1a617622 Mon Sep 17 00:00:00 2001 From: JoshuaR <36710177+joshuarestivo@users.noreply.github.com> Date: Sun, 13 Oct 2024 19:17:27 +0000 Subject: [PATCH 3/8] Add Deal Elements column to default frontend Deals list view --- crm/fcrm/doctype/crm_deal/crm_deal.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.py b/crm/fcrm/doctype/crm_deal/crm_deal.py index 395619b73..1c37c2015 100644 --- a/crm/fcrm/doctype/crm_deal/crm_deal.py +++ b/crm/fcrm/doctype/crm_deal/crm_deal.py @@ -135,6 +135,13 @@ def default_list_data(): 'options': 'CRM Organization', 'width': '11rem', }, + { + 'label': 'Deal Elements', + 'type': 'Table MultiSelect', + 'key': 'deal_elements', + 'options': 'CRM Deal Elements', + 'width': '12rem', + }, { 'label': 'Amount', 'type': 'Currency', @@ -175,6 +182,7 @@ def default_list_data(): rows = [ "name", "organization", + "deal_elements", "annual_revenue", "status", "email", From 42c973e576cd7f7064ec61952bb7ab652a505bed Mon Sep 17 00:00:00 2001 From: JoshuaR <36710177+joshuarestivo@users.noreply.github.com> Date: Mon, 14 Oct 2024 12:18:49 +0000 Subject: [PATCH 4/8] Organize CRM Deal fields in doctype tabs --- crm/fcrm/doctype/crm_deal/crm_deal.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.json b/crm/fcrm/doctype/crm_deal/crm_deal.json index e3d6f8bbd..95a1abb92 100644 --- a/crm/fcrm/doctype/crm_deal/crm_deal.json +++ b/crm/fcrm/doctype/crm_deal/crm_deal.json @@ -10,15 +10,15 @@ "tab_6_tab", "details_section", "deal_elements", - "organization_tab", + "probability", + "close_date", "naming_series", - "organization", + "column_break_tukx", "next_step", - "probability", - "column_break_ijan", "status", - "close_date", "deal_owner", + "organization_tab", + "organization", "contacts_tab", "contacts", "contact", @@ -262,10 +262,6 @@ "fieldtype": "Data", "label": "Lead Name" }, - { - "fieldname": "column_break_ijan", - "fieldtype": "Column Break" - }, { "fieldname": "lead_details_tab", "fieldtype": "Tab Break", @@ -353,11 +349,15 @@ "fieldtype": "Table MultiSelect", "label": "Deal Elements", "options": "CRM Deal Elements" + }, + { + "fieldname": "column_break_tukx", + "fieldtype": "Column Break" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2024-10-13 07:25:20.676662", + "modified": "2024-10-14 07:18:34.660756", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Deal", From 348130fe4c33c4822ac369c497017e00bc2ce402 Mon Sep 17 00:00:00 2001 From: JoshuaR <36710177+joshuarestivo@users.noreply.github.com> Date: Thu, 17 Oct 2024 14:26:40 +0000 Subject: [PATCH 5/8] Fix deal elements not saving --- crm/fcrm/doctype/crm_deal/crm_deal.json | 2 +- crm/fcrm/doctype/crm_deal_element/crm_deal_element.json | 2 +- crm/fcrm/doctype/crm_deal_elements/crm_deal_elements.json | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.json b/crm/fcrm/doctype/crm_deal/crm_deal.json index 95a1abb92..45d9860f4 100644 --- a/crm/fcrm/doctype/crm_deal/crm_deal.json +++ b/crm/fcrm/doctype/crm_deal/crm_deal.json @@ -357,7 +357,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2024-10-14 07:18:34.660756", + "modified": "2024-10-17 09:18:00.677849", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Deal", diff --git a/crm/fcrm/doctype/crm_deal_element/crm_deal_element.json b/crm/fcrm/doctype/crm_deal_element/crm_deal_element.json index 624efebdf..83de2fb7f 100644 --- a/crm/fcrm/doctype/crm_deal_element/crm_deal_element.json +++ b/crm/fcrm/doctype/crm_deal_element/crm_deal_element.json @@ -32,7 +32,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2024-10-13 13:04:27.910341", + "modified": "2024-10-17 09:22:09.844125", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Deal Element", diff --git a/crm/fcrm/doctype/crm_deal_elements/crm_deal_elements.json b/crm/fcrm/doctype/crm_deal_elements/crm_deal_elements.json index d25bb0140..e3d5f38a7 100644 --- a/crm/fcrm/doctype/crm_deal_elements/crm_deal_elements.json +++ b/crm/fcrm/doctype/crm_deal_elements/crm_deal_elements.json @@ -12,6 +12,9 @@ { "fieldname": "deal_elements", "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "in_standard_filter": 1, "label": "Deal Elements", "options": "CRM Deal Element" } @@ -19,7 +22,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2024-10-13 13:07:29.615600", + "modified": "2024-10-17 09:22:29.942549", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Deal Elements", From f6a94f0f50b9e852680c9250a31a3751135fea2c Mon Sep 17 00:00:00 2001 From: saadchaudhaary Date: Fri, 18 Oct 2024 19:58:46 +0530 Subject: [PATCH 6/8] get Child data in crm.api.doc.get_data --- crm/api/doc.py | 20 ++++++++ crm/fcrm/doctype/data_doctype/data_doctype.js | 8 ++++ .../doctype/data_doctype/data_doctype.json | 46 +++++++++++++++++++ crm/fcrm/doctype/data_doctype/data_doctype.py | 9 ++++ 4 files changed, 83 insertions(+) create mode 100644 crm/fcrm/doctype/data_doctype/data_doctype.js create mode 100644 crm/fcrm/doctype/data_doctype/data_doctype.json create mode 100644 crm/fcrm/doctype/data_doctype/data_doctype.py diff --git a/crm/api/doc.py b/crm/api/doc.py index 576127a1a..a0a19312b 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -303,6 +303,26 @@ def get_data( page_length=page_length, ) or [] + + # Fetch child table data if requested + include_child_tables = frappe.get_all('Data Doctype', fields=['name']) + include_child_tables_list = [entry['name'] for entry in include_child_tables] + + if doctype in include_child_tables_list: + meta = frappe.get_meta(doctype) + child_tables = [df for df in meta.fields if df.fieldtype == "Table"] + + for record in data: + record['child_tables'] = {} + for child_table in child_tables: + child_doctype = child_table.options + child_records = frappe.get_all( + child_doctype, + fields="*", + filters={"parent": record['name']} + ) + record['child_tables'][child_table.fieldname] = child_records + if view_type == "kanban": if not rows: rows = default_rows diff --git a/crm/fcrm/doctype/data_doctype/data_doctype.js b/crm/fcrm/doctype/data_doctype/data_doctype.js new file mode 100644 index 000000000..cbd55cfa8 --- /dev/null +++ b/crm/fcrm/doctype/data_doctype/data_doctype.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("Data Doctype", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/doctype/data_doctype/data_doctype.json b/crm/fcrm/doctype/data_doctype/data_doctype.json new file mode 100644 index 000000000..d422cb464 --- /dev/null +++ b/crm/fcrm/doctype/data_doctype/data_doctype.json @@ -0,0 +1,46 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "field:data_doctype", + "creation": "2024-10-18 05:14:39.520861", + "doctype": "DocType", + "engine": "InnoDB", + "field_order": [ + "data_doctype" + ], + "fields": [ + { + "fieldname": "data_doctype", + "fieldtype": "Link", + "label": "Data Doctype", + "link_filters": "[[\"DocType\",\"istable\",\"=\",0],[\"DocType\",\"issingle\",\"=\",0]]", + "options": "DocType", + "unique": 1 + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2024-10-18 05:16:12.696953", + "modified_by": "Administrator", + "module": "FCRM", + "name": "Data Doctype", + "naming_rule": "By fieldname", + "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": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/doctype/data_doctype/data_doctype.py b/crm/fcrm/doctype/data_doctype/data_doctype.py new file mode 100644 index 000000000..4966469a6 --- /dev/null +++ b/crm/fcrm/doctype/data_doctype/data_doctype.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 DataDoctype(Document): + pass From 3e4b5c701cca0fbc80194351d315c3772536aa8c Mon Sep 17 00:00:00 2001 From: saadchaudhaary Date: Fri, 18 Oct 2024 20:24:53 +0530 Subject: [PATCH 7/8] get Child data table and muti select --- crm/api/doc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crm/api/doc.py b/crm/api/doc.py index a0a19312b..0246bdc68 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -310,7 +310,7 @@ def get_data( if doctype in include_child_tables_list: meta = frappe.get_meta(doctype) - child_tables = [df for df in meta.fields if df.fieldtype == "Table"] + child_tables = [df for df in meta.fields if df.fieldtype in ["Table","Table MultiSelect" ] ] for record in data: record['child_tables'] = {} From f3d80dfe592621dc89efe0216445d6539b8224e6 Mon Sep 17 00:00:00 2001 From: saadchaudhaary Date: Fri, 25 Oct 2024 22:54:38 +0530 Subject: [PATCH 8/8] feat: [deal-elements] Extends get_deal to fetch child table data * feat: Add child table data to CRM Deal in get_deal method - Enhanced the get_deal function to retrieve and include child table data for CRM Deal. - Modified query to return all child tables linked to CRM Deal, including their respective records. - Added support for fetching contacts, fields metadata, form script, and assigned users for the deal. * Remove unnecessary files from tracking * crm.fcrm.doctype.crm_deal.api.update_crm_deal_elements api for add deal elements in crm deal * crm.fcrm.doctype.crm_deal.api.update_crm_deal_elements api for add deal elements in crm deal * crm.fcrm.doctype.crm_deal.api.update_crm_deal_elements api for add deal elements in crm deal with methods=[POST, PUT] * Remove stray whitespace * crm.fcrm.doctype.crm_deal.api.get_deal_elements for getting the list of deal elements --- crm/fcrm/doctype/crm_deal/api.py | 47 +++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/crm/fcrm/doctype/crm_deal/api.py b/crm/fcrm/doctype/crm_deal/api.py index 76a764aed..b76a0561f 100644 --- a/crm/fcrm/doctype/crm_deal/api.py +++ b/crm/fcrm/doctype/crm_deal/api.py @@ -20,6 +20,20 @@ def get_deal(name): frappe.throw(_("Deal not found"), frappe.DoesNotExistError) deal = deal.pop() + # Get all child table doctypes linked to CRM Deal + meta = frappe.get_meta("CRM Deal") + child_tables = [df for df in meta.fields if df.fieldtype in ["Table","Table MultiSelect" ] ] + + deal['child_tables'] = {} + + for child_table in child_tables: + child_doctype = child_table.options + child_records = frappe.get_all( + child_doctype, + fields="*", + filters={"parent": deal['name']} + ) + deal['child_tables'][child_table.fieldname] = child_records deal["contacts"] = frappe.get_all( "CRM Contacts", @@ -63,4 +77,35 @@ def get_primary_mobile_no(contact): "is_primary": is_primary, } deal_contacts.append(_contact) - return deal_contacts \ No newline at end of file + return deal_contacts + +@frappe.whitelist(methods=["POST", "PUT"]) +def update_crm_deal_elements(name, deal_elements): + # Fetch the CRM Deal by name + deal = frappe.get_doc("CRM Deal", name) + + # Clear the existing deal elements + deal.set("deal_elements", []) + + # Add new deal elements from the list of strings + for element in deal_elements: + deal.append("deal_elements", { + "deal_elements": element, # now element is the string itself + "parent": name, + "parentfield": "deal_elements", + "parenttype": "CRM Deal", + "doctype": "CRM Deal Elements" + }) + + # Save the updated CRM Deal document + deal.save(ignore_permissions=True) + frappe.db.commit() + + return {"name":name, "deal_elements":deal.deal_elements} + + +@frappe.whitelist(methods=["GET"]) +def get_deal_elements(): + # Fetch all CRM Deal Elements + deal_elements = frappe.get_all("CRM Deal Element", fields=["name"]) + return deal_elements \ No newline at end of file