diff --git a/crm/api/doc.py b/crm/api/doc.py index 461cac1d..4ad990c1 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -3,6 +3,8 @@ from frappe.model.document import get_controller from frappe.model import no_value_fields from pypika import Criterion +from crm.api.views import get_views + @frappe.whitelist() def sort_options(doctype: str): @@ -164,14 +166,6 @@ def get_list_data( "row_count": len(data), } -def get_views(doctype): - views = frappe.get_all( - "CRM View Settings", - fields=["*"], - filters={"dt": doctype, "user": frappe.session.user} - ) - return views - def get_doctype_fields(doctype): not_allowed_fieldtypes = [ diff --git a/crm/api/session.py b/crm/api/session.py index 7650d3c1..b9435b16 100644 --- a/crm/api/session.py +++ b/crm/api/session.py @@ -16,6 +16,10 @@ def get_users(): for user in users: if frappe.session.user == user.name: user.session_user = True + + user.is_manager = ( + "Sales Manager" in frappe.get_roles(user.name) or user.name == "Administrator" + ) return users @frappe.whitelist() diff --git a/crm/api/views.py b/crm/api/views.py new file mode 100644 index 00000000..6a95adbf --- /dev/null +++ b/crm/api/views.py @@ -0,0 +1,19 @@ +import frappe +from pypika import Criterion + + +@frappe.whitelist() +def get_views(doctype): + if frappe.session.user == "Guest": + frappe.throw("Authentication failed", exc=frappe.AuthenticationError) + + View = frappe.qb.DocType("CRM View Settings") + query = ( + frappe.qb.from_(View) + .select("*") + .where(Criterion.any([View.user == '', View.user == frappe.session.user])) + ) + if doctype: + query = query.where(View.dt == doctype) + views = query.run(as_dict=True) + return views \ No newline at end of file diff --git a/crm/fcrm/doctype/crm_call_log/crm_call_log.json b/crm/fcrm/doctype/crm_call_log/crm_call_log.json index cf7f3a1c..6cb6191c 100644 --- a/crm/fcrm/doctype/crm_call_log/crm_call_log.json +++ b/crm/fcrm/doctype/crm_call_log/crm_call_log.json @@ -127,7 +127,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2024-01-18 13:27:19.776926", + "modified": "2024-01-19 21:51:52.173476", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Call Log", @@ -142,7 +142,19 @@ "print": 1, "read": 1, "report": 1, - "role": "System Manager", + "role": "Sales User", + "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 } diff --git a/crm/fcrm/doctype/crm_communication_status/crm_communication_status.json b/crm/fcrm/doctype/crm_communication_status/crm_communication_status.json index be7aeb93..ff3163e9 100644 --- a/crm/fcrm/doctype/crm_communication_status/crm_communication_status.json +++ b/crm/fcrm/doctype/crm_communication_status/crm_communication_status.json @@ -20,7 +20,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-12-13 13:28:38.746199", + "modified": "2024-01-19 21:55:17.952032", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Communication Status", @@ -35,7 +35,19 @@ "print": 1, "read": 1, "report": 1, - "role": "System Manager", + "role": "Sales User", + "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 } diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.json b/crm/fcrm/doctype/crm_deal/crm_deal.json index 12115e15..c8b497a7 100644 --- a/crm/fcrm/doctype/crm_deal/crm_deal.json +++ b/crm/fcrm/doctype/crm_deal/crm_deal.json @@ -275,7 +275,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2024-01-19 17:13:41.931398", + "modified": "2024-01-19 21:43:58.940722", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Deal", @@ -290,7 +290,19 @@ "print": 1, "read": 1, "report": 1, - "role": "System Manager", + "role": "Sales User", + "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 } diff --git a/crm/fcrm/doctype/crm_deal_status/crm_deal_status.json b/crm/fcrm/doctype/crm_deal_status/crm_deal_status.json index d683bf68..b0374ca1 100644 --- a/crm/fcrm/doctype/crm_deal_status/crm_deal_status.json +++ b/crm/fcrm/doctype/crm_deal_status/crm_deal_status.json @@ -36,7 +36,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-11-29 12:52:03.070218", + "modified": "2024-01-19 21:56:44.552134", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Deal Status", @@ -51,7 +51,19 @@ "print": 1, "read": 1, "report": 1, - "role": "System Manager", + "role": "Sales User", + "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 } diff --git a/crm/fcrm/doctype/crm_form_script/crm_form_script.json b/crm/fcrm/doctype/crm_form_script/crm_form_script.json index dccf506c..b883e804 100644 --- a/crm/fcrm/doctype/crm_form_script/crm_form_script.json +++ b/crm/fcrm/doctype/crm_form_script/crm_form_script.json @@ -45,7 +45,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-12-29 12:14:45.706725", + "modified": "2024-01-19 21:52:46.078626", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Form Script", @@ -60,7 +60,7 @@ "print": 1, "read": 1, "report": 1, - "role": "System Manager", + "role": "Sales Manager", "share": 1, "write": 1 } diff --git a/crm/fcrm/doctype/crm_holiday_list/crm_holiday_list.json b/crm/fcrm/doctype/crm_holiday_list/crm_holiday_list.json index a6a8ab6b..066f12ee 100644 --- a/crm/fcrm/doctype/crm_holiday_list/crm_holiday_list.json +++ b/crm/fcrm/doctype/crm_holiday_list/crm_holiday_list.json @@ -85,7 +85,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-12-14 11:18:27.236817", + "modified": "2024-01-19 21:54:54.809445", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Holiday List", @@ -100,7 +100,19 @@ "print": 1, "read": 1, "report": 1, - "role": "System Manager", + "role": "Sales User", + "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 } diff --git a/crm/fcrm/doctype/crm_industry/crm_industry.json b/crm/fcrm/doctype/crm_industry/crm_industry.json index 9523cca4..d3d15a71 100644 --- a/crm/fcrm/doctype/crm_industry/crm_industry.json +++ b/crm/fcrm/doctype/crm_industry/crm_industry.json @@ -21,7 +21,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-07-24 19:40:31.980882", + "modified": "2024-01-19 21:57:02.025918", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Industry", @@ -36,7 +36,19 @@ "print": 1, "read": 1, "report": 1, - "role": "System Manager", + "role": "Sales User", + "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 } diff --git a/crm/fcrm/doctype/crm_lead/crm_lead.json b/crm/fcrm/doctype/crm_lead/crm_lead.json index 3f61682c..ba851add 100644 --- a/crm/fcrm/doctype/crm_lead/crm_lead.json +++ b/crm/fcrm/doctype/crm_lead/crm_lead.json @@ -293,7 +293,7 @@ "image_field": "image", "index_web_pages_for_search": 1, "links": [], - "modified": "2024-01-06 18:44:03.946528", + "modified": "2024-01-19 21:52:28.923346", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Lead", @@ -308,7 +308,19 @@ "print": 1, "read": 1, "report": 1, - "role": "System Manager", + "role": "Sales User", + "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 } diff --git a/crm/fcrm/doctype/crm_lead_source/crm_lead_source.json b/crm/fcrm/doctype/crm_lead_source/crm_lead_source.json index 0d0f120b..23aea6f6 100644 --- a/crm/fcrm/doctype/crm_lead_source/crm_lead_source.json +++ b/crm/fcrm/doctype/crm_lead_source/crm_lead_source.json @@ -29,7 +29,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-11-23 13:11:40.743731", + "modified": "2024-01-19 21:56:04.702254", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Lead Source", @@ -44,7 +44,19 @@ "print": 1, "read": 1, "report": 1, - "role": "System Manager", + "role": "Sales User", + "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 } diff --git a/crm/fcrm/doctype/crm_lead_status/crm_lead_status.json b/crm/fcrm/doctype/crm_lead_status/crm_lead_status.json index a13281ba..587f6b61 100644 --- a/crm/fcrm/doctype/crm_lead_status/crm_lead_status.json +++ b/crm/fcrm/doctype/crm_lead_status/crm_lead_status.json @@ -37,7 +37,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-11-29 12:52:25.641581", + "modified": "2024-01-19 21:56:16.872924", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Lead Status", @@ -52,7 +52,19 @@ "print": 1, "read": 1, "report": 1, - "role": "System Manager", + "role": "Sales User", + "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 } diff --git a/crm/fcrm/doctype/crm_note/crm_note.json b/crm/fcrm/doctype/crm_note/crm_note.json index faa95bd8..3726bdd2 100644 --- a/crm/fcrm/doctype/crm_note/crm_note.json +++ b/crm/fcrm/doctype/crm_note/crm_note.json @@ -49,7 +49,7 @@ "link_fieldname": "note" } ], - "modified": "2023-11-23 13:11:39.812793", + "modified": "2024-01-19 21:56:30.123334", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Note", @@ -63,7 +63,19 @@ "print": 1, "read": 1, "report": 1, - "role": "System Manager", + "role": "Sales User", + "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 } diff --git a/crm/fcrm/doctype/crm_organization/crm_organization.json b/crm/fcrm/doctype/crm_organization/crm_organization.json index 1b300b94..bc1a042c 100644 --- a/crm/fcrm/doctype/crm_organization/crm_organization.json +++ b/crm/fcrm/doctype/crm_organization/crm_organization.json @@ -65,7 +65,7 @@ "image_field": "organization_logo", "index_web_pages_for_search": 1, "links": [], - "modified": "2024-01-04 18:57:52.519305", + "modified": "2024-01-19 21:53:14.945857", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Organization", @@ -80,7 +80,19 @@ "print": 1, "read": 1, "report": 1, - "role": "System Manager", + "role": "Sales User", + "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 } diff --git a/crm/fcrm/doctype/crm_service_level_agreement/crm_service_level_agreement.json b/crm/fcrm/doctype/crm_service_level_agreement/crm_service_level_agreement.json index e563ccea..81fe90c9 100644 --- a/crm/fcrm/doctype/crm_service_level_agreement/crm_service_level_agreement.json +++ b/crm/fcrm/doctype/crm_service_level_agreement/crm_service_level_agreement.json @@ -115,7 +115,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-12-15 11:50:29.956775", + "modified": "2024-01-19 21:54:25.831753", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Service Level Agreement", @@ -130,7 +130,7 @@ "print": 1, "read": 1, "report": 1, - "role": "System Manager", + "role": "Sales Manager", "share": 1, "write": 1 } diff --git a/crm/fcrm/doctype/crm_task/crm_task.json b/crm/fcrm/doctype/crm_task/crm_task.json index 8525439c..bb962714 100644 --- a/crm/fcrm/doctype/crm_task/crm_task.json +++ b/crm/fcrm/doctype/crm_task/crm_task.json @@ -87,7 +87,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-11-23 13:11:39.233502", + "modified": "2024-01-19 21:55:42.654547", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Task", @@ -102,7 +102,19 @@ "print": 1, "read": 1, "report": 1, - "role": "System Manager", + "role": "Sales User", + "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 } diff --git a/crm/fcrm/doctype/crm_territory/crm_territory.json b/crm/fcrm/doctype/crm_territory/crm_territory.json index 09d96e75..91e3b09c 100644 --- a/crm/fcrm/doctype/crm_territory/crm_territory.json +++ b/crm/fcrm/doctype/crm_territory/crm_territory.json @@ -13,10 +13,10 @@ "section_break_qhaf", "old_parent", "parent_crm_territory", - "is_group", "column_break_pypy", "lft", - "rgt" + "rgt", + "is_group" ], "fields": [ { @@ -90,7 +90,7 @@ "index_web_pages_for_search": 1, "is_tree": 1, "links": [], - "modified": "2024-01-05 12:26:25.485080", + "modified": "2024-01-19 21:53:53.451891", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Territory", @@ -106,7 +106,19 @@ "print": 1, "read": 1, "report": 1, - "role": "System Manager", + "role": "Sales User", + "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 } diff --git a/crm/fcrm/doctype/crm_view_settings/crm_view_settings.json b/crm/fcrm/doctype/crm_view_settings/crm_view_settings.json index 6cbc383e..d4574d55 100644 --- a/crm/fcrm/doctype/crm_view_settings/crm_view_settings.json +++ b/crm/fcrm/doctype/crm_view_settings/crm_view_settings.json @@ -11,6 +11,7 @@ "dt", "route_name", "pinned", + "public", "columns_tab", "load_default_columns", "columns", @@ -97,11 +98,17 @@ "fieldname": "load_default_columns", "fieldtype": "Check", "label": "Load Default Columns" + }, + { + "default": "0", + "fieldname": "public", + "fieldtype": "Check", + "label": "Public" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2024-01-03 16:54:52.195687", + "modified": "2024-01-19 21:44:52.285420", "modified_by": "Administrator", "module": "FCRM", "name": "CRM View Settings", @@ -116,7 +123,19 @@ "print": 1, "read": 1, "report": 1, - "role": "System Manager", + "role": "Sales User", + "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 } diff --git a/crm/fcrm/doctype/crm_view_settings/crm_view_settings.py b/crm/fcrm/doctype/crm_view_settings/crm_view_settings.py index 5eba8b6e..19e0ab04 100644 --- a/crm/fcrm/doctype/crm_view_settings/crm_view_settings.py +++ b/crm/fcrm/doctype/crm_view_settings/crm_view_settings.py @@ -63,6 +63,16 @@ def delete(name): if frappe.db.exists("CRM View Settings", name): frappe.delete_doc("CRM View Settings", name) +@frappe.whitelist() +def public(name, value): + if "Sales Manager" not in frappe.get_roles() or frappe.session.user != "Administrator": + frappe.throw("Not permitted", frappe.PermissionError) + + doc = frappe.get_doc("CRM View Settings", name) + doc.public = value + doc.user = "" if value else frappe.session.user + doc.save() + @frappe.whitelist() def pin(name, value): doc = frappe.get_doc("CRM View Settings", name) diff --git a/crm/fcrm/doctype/twilio_agents/twilio_agents.json b/crm/fcrm/doctype/twilio_agents/twilio_agents.json index c54aaf36..65251130 100644 --- a/crm/fcrm/doctype/twilio_agents/twilio_agents.json +++ b/crm/fcrm/doctype/twilio_agents/twilio_agents.json @@ -51,7 +51,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-08-17 22:21:00.606384", + "modified": "2024-01-19 21:57:18.626669", "modified_by": "Administrator", "module": "FCRM", "name": "Twilio Agents", @@ -66,7 +66,7 @@ "print": 1, "read": 1, "report": 1, - "role": "System Manager", + "role": "Sales Manager", "share": 1, "write": 1 } diff --git a/frontend/src/components/Layouts/AppSidebar.vue b/frontend/src/components/Layouts/AppSidebar.vue index 4b5d891d..5b1cd6e6 100644 --- a/frontend/src/components/Layouts/AppSidebar.vue +++ b/frontend/src/components/Layouts/AppSidebar.vue @@ -15,25 +15,54 @@ class="mx-2 my-0.5" /> +
+
+ Public Views +
+
+ +
-
- Pinned Views -
+ Pinned Views +
+
-
+