feat: Export CRM dashboard (#22778)

* feat: Exported CRM dashboard

* feat: Export CRM Dashboard

* fix: adding company in all dashboard and number card
This commit is contained in:
Anupam Kumar 2020-07-22 18:16:57 +05:30 committed by GitHub
parent 93afbe143b
commit e519334dfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 334 additions and 221 deletions

View File

@ -0,0 +1,58 @@
{
"cards": [
{
"card": "New Lead (Last 1 Month)"
},
{
"card": "New Opportunity (Last 1 Month)"
},
{
"card": "Won Opportunity (Last 1 Month)"
},
{
"card": "Open Opportunity"
}
],
"charts": [
{
"chart": "Incoming Leads",
"width": "Full"
},
{
"chart": "Opportunity Trends",
"width": "Full"
},
{
"chart": "Won Opportunities",
"width": "Full"
},
{
"chart": "Territory Wise Opportunity Count",
"width": "Half"
},
{
"chart": "Opportunities via Campaigns",
"width": "Half"
},
{
"chart": "Territory Wise Sales",
"width": "Full"
},
{
"chart": "Lead Source",
"width": "Half"
}
],
"creation": "2020-07-20 20:17:15.985657",
"dashboard_name": "CRM",
"docstatus": 0,
"doctype": "Dashboard",
"idx": 0,
"is_default": 0,
"is_standard": 1,
"modified": "2020-07-21 18:56:47.230053",
"modified_by": "Administrator",
"module": "CRM",
"name": "CRM",
"owner": "Administrator"
}

View File

@ -0,0 +1,28 @@
{
"based_on": "creation",
"chart_name": "Incoming Leads",
"chart_type": "Count",
"creation": "2020-07-20 20:17:15.639164",
"custom_options": "{\"type\": \"line\", \"axisOptions\": {\"shortenYAxisNumbers\": 1}, \"tooltipOptions\": {}, \"lineOptions\": {\"regionFill\": 1}}",
"docstatus": 0,
"doctype": "Dashboard Chart",
"document_type": "Lead",
"dynamic_filters_json": "[[\"Lead\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]",
"filters_json": "[]",
"idx": 0,
"is_public": 1,
"is_standard": 1,
"last_synced_on": "2020-07-22 15:49:19.896501",
"modified": "2020-07-22 16:06:34.941729",
"modified_by": "Administrator",
"module": "CRM",
"name": "Incoming Leads",
"number_of_groups": 0,
"owner": "Administrator",
"time_interval": "Weekly",
"timeseries": 1,
"timespan": "Last Quarter",
"type": "Bar",
"use_report_chart": 0,
"y_axis": []
}

View File

@ -0,0 +1,27 @@
{
"chart_name": "Lead Source",
"chart_type": "Group By",
"creation": "2020-07-20 20:17:15.842106",
"custom_options": "{\"truncateLegends\": 1, \"maxSlices\": 8}",
"docstatus": 0,
"doctype": "Dashboard Chart",
"document_type": "Lead",
"dynamic_filters_json": "[[\"Lead\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]",
"filters_json": "[]",
"group_by_based_on": "source",
"group_by_type": "Count",
"idx": 0,
"is_public": 1,
"is_standard": 1,
"last_synced_on": "2020-07-22 16:11:14.170636",
"modified": "2020-07-22 16:13:38.696710",
"modified_by": "Administrator",
"module": "CRM",
"name": "Lead Source",
"number_of_groups": 0,
"owner": "Administrator",
"timeseries": 0,
"type": "Donut",
"use_report_chart": 0,
"y_axis": []
}

View File

@ -0,0 +1,27 @@
{
"chart_name": "Opportunities via Campaigns",
"chart_type": "Group By",
"creation": "2020-07-20 20:17:15.705402",
"custom_options": "{\"truncateLegends\": 1, \"maxSlices\": 8}",
"docstatus": 0,
"doctype": "Dashboard Chart",
"document_type": "Opportunity",
"dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]",
"filters_json": "[]",
"group_by_based_on": "campaign",
"group_by_type": "Count",
"idx": 0,
"is_public": 1,
"is_standard": 1,
"last_synced_on": "2020-07-22 15:45:32.572011",
"modified": "2020-07-22 16:10:02.497726",
"modified_by": "Administrator",
"module": "CRM",
"name": "Opportunities via Campaigns",
"number_of_groups": 0,
"owner": "Administrator",
"timeseries": 0,
"type": "Pie",
"use_report_chart": 0,
"y_axis": []
}

View File

@ -0,0 +1,28 @@
{
"based_on": "creation",
"chart_name": "Opportunity Trends",
"chart_type": "Count",
"creation": "2020-07-20 20:17:15.672124",
"custom_options": "",
"docstatus": 0,
"doctype": "Dashboard Chart",
"document_type": "Opportunity",
"dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]",
"filters_json": "[]",
"idx": 0,
"is_public": 1,
"is_standard": 1,
"last_synced_on": "2020-07-22 15:45:32.590967",
"modified": "2020-07-22 16:08:33.100532",
"modified_by": "Administrator",
"module": "CRM",
"name": "Opportunity Trends",
"number_of_groups": 0,
"owner": "Administrator",
"time_interval": "Weekly",
"timeseries": 1,
"timespan": "Last Quarter",
"type": "Bar",
"use_report_chart": 0,
"y_axis": []
}

View File

@ -0,0 +1,27 @@
{
"chart_name": "Territory Wise Opportunity Count",
"chart_type": "Group By",
"creation": "2020-07-20 20:17:15.774176",
"custom_options": "{\"truncateLegends\": 1, \"maxSlices\": 8}",
"docstatus": 0,
"doctype": "Dashboard Chart",
"document_type": "Opportunity",
"dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]",
"filters_json": "[]",
"group_by_based_on": "territory",
"group_by_type": "Count",
"idx": 0,
"is_public": 1,
"is_standard": 1,
"last_synced_on": "2020-07-22 15:45:32.134026",
"modified": "2020-07-22 16:09:42.921547",
"modified_by": "Administrator",
"module": "CRM",
"name": "Territory Wise Opportunity Count",
"number_of_groups": 0,
"owner": "Administrator",
"timeseries": 0,
"type": "Donut",
"use_report_chart": 0,
"y_axis": []
}

View File

@ -0,0 +1,28 @@
{
"aggregate_function_based_on": "opportunity_amount",
"chart_name": "Territory Wise Sales",
"chart_type": "Group By",
"creation": "2020-07-20 20:17:15.809008",
"custom_options": "",
"docstatus": 0,
"doctype": "Dashboard Chart",
"document_type": "Opportunity",
"dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]",
"filters_json": "[[\"Opportunity\",\"status\",\"=\",\"Converted\",false]]",
"group_by_based_on": "territory",
"group_by_type": "Sum",
"idx": 0,
"is_public": 1,
"is_standard": 1,
"last_synced_on": "2020-07-22 15:45:32.501313",
"modified": "2020-07-22 16:10:28.308110",
"modified_by": "Administrator",
"module": "CRM",
"name": "Territory Wise Sales",
"number_of_groups": 0,
"owner": "Administrator",
"timeseries": 0,
"type": "Bar",
"use_report_chart": 0,
"y_axis": []
}

View File

@ -0,0 +1,27 @@
{
"based_on": "modified",
"chart_name": "Won Opportunities",
"chart_type": "Count",
"creation": "2020-07-20 20:17:15.738889",
"docstatus": 0,
"doctype": "Dashboard Chart",
"document_type": "Opportunity",
"dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]",
"filters_json": "[[\"Opportunity\",\"status\",\"=\",\"Converted\",false]]",
"idx": 0,
"is_public": 1,
"is_standard": 1,
"last_synced_on": "2020-07-22 15:45:32.575964",
"modified": "2020-07-22 16:09:14.265231",
"modified_by": "Administrator",
"module": "CRM",
"name": "Won Opportunities",
"number_of_groups": 0,
"owner": "Administrator",
"time_interval": "Monthly",
"timeseries": 1,
"timespan": "Last Year",
"type": "Bar",
"use_report_chart": 0,
"y_axis": []
}

View File

@ -1,221 +0,0 @@
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
import frappe, erpnext, json
from frappe import _
def get_data():
return frappe._dict({
"dashboards": get_dashboards(),
"charts": get_charts(),
"number_cards": get_number_cards()
})
def get_dashboards():
return [{
"doctype": "Dashboard",
"name": "CRM",
"dashboard_name": "CRM",
"charts": [
{ "chart": "Incoming Leads", "width": "Full" },
{ "chart": "Opportunity Trends", "width": "Full"},
{ "chart": "Won Opportunities", "width": "Full" },
{ "chart": "Territory Wise Opportunity Count", "width": "Half"},
{ "chart": "Opportunities via Campaigns", "width": "Half" },
{ "chart": "Territory Wise Sales", "width": "Full"},
{ "chart": "Lead Source", "width": "Half"}
],
"cards": [
{ "card": "New Lead (Last 1 Month)" },
{ "card": "New Opportunity (Last 1 Month)" },
{ "card": "Won Opportunity (Last 1 Month)" },
{ "card": "Open Opportunity"},
]
}]
def get_company_for_dashboards():
company = frappe.defaults.get_defaults().company
if company:
return company
else:
company_list = frappe.get_list("Company")
if company_list:
return company_list[0].name
return None
def get_charts():
company = get_company_for_dashboards()
return [{
"name": "Incoming Leads",
"doctype": "Dashboard Chart",
"time_interval": "Yearly",
"chart_type": "Count",
"chart_name": _("Incoming Leads"),
"timespan": "Last Quarter",
"time_interval": "Weekly",
"document_type": "Lead",
"based_on": "creation",
'is_public': 1,
'timeseries': 1,
"owner": "Administrator",
"filters_json": json.dumps([]),
"type": "Bar"
},
{
"name": "Opportunity Trends",
"doctype": "Dashboard Chart",
"time_interval": "Yearly",
"chart_type": "Count",
"chart_name": _("Opportunity Trends"),
"timespan": "Last Quarter",
"time_interval": "Weekly",
"document_type": "Opportunity",
"based_on": "creation",
'is_public': 1,
'timeseries': 1,
"owner": "Administrator",
"filters_json": json.dumps([["Opportunity", "company", "=", company, False]]),
"type": "Bar"
},
{
"name": "Opportunities via Campaigns",
"chart_name": _("Opportunities via Campaigns"),
"doctype": "Dashboard Chart",
"chart_type": "Group By",
"group_by_type": "Count",
"group_by_based_on": "campaign",
"document_type": "Opportunity",
'is_public': 1,
'timeseries': 1,
"owner": "Administrator",
"filters_json": json.dumps([["Opportunity", "company", "=", company, False]]),
"type": "Pie",
"custom_options": json.dumps({
"truncateLegends": 1,
"maxSlices": 8
})
},
{
"name": "Won Opportunities",
"doctype": "Dashboard Chart",
"time_interval": "Yearly",
"chart_type": "Count",
"chart_name": _("Won Opportunities"),
"timespan": "Last Year",
"time_interval": "Monthly",
"document_type": "Opportunity",
"based_on": "modified",
'is_public': 1,
'timeseries': 1,
"owner": "Administrator",
"filters_json": json.dumps([
["Opportunity", "company", "=", company, False],
["Opportunity", "status", "=", "Converted", False]]),
"type": "Bar"
},
{
"name": "Territory Wise Opportunity Count",
"doctype": "Dashboard Chart",
"chart_type": "Group By",
"group_by_type": "Count",
"group_by_based_on": "territory",
"chart_name": _("Territory Wise Opportunity Count"),
"document_type": "Opportunity",
'is_public': 1,
"filters_json": json.dumps([
["Opportunity", "company", "=", company, False]
]),
"owner": "Administrator",
"type": "Donut",
"custom_options": json.dumps({
"truncateLegends": 1,
"maxSlices": 8
})
},
{
"name": "Territory Wise Sales",
"doctype": "Dashboard Chart",
"chart_type": "Group By",
"group_by_type": "Sum",
"group_by_based_on": "territory",
"chart_name": _("Territory Wise Sales"),
"aggregate_function_based_on": "opportunity_amount",
"document_type": "Opportunity",
'is_public': 1,
"owner": "Administrator",
"filters_json": json.dumps([
["Opportunity", "company", "=", company, False],
["Opportunity", "status", "=", "Converted", False]
]),
"type": "Bar"
},
{
"name": "Lead Source",
"doctype": "Dashboard Chart",
"chart_type": "Group By",
"group_by_type": "Count",
"group_by_based_on": "source",
"chart_name": _("Lead Source"),
"document_type": "Lead",
'is_public': 1,
"owner": "Administrator",
"type": "Pie",
"custom_options": json.dumps({
"truncateLegends": 1,
"maxSlices": 8
})
}]
def get_number_cards():
return [{
"doctype": "Number Card",
"document_type": "Lead",
"name": "New Lead (Last 1 Month)",
"filters_json": json.dumps([
["Lead", "creation", "Timespan", "last month"]
]),
"function": "Count",
"is_public": 1,
"label": _("New Lead (Last 1 Month)"),
"show_percentage_stats": 1,
"stats_time_interval": "Daily"
},
{
"doctype": "Number Card",
"document_type": "Opportunity",
"name": "New Opportunity (Last 1 Month)",
"filters_json": json.dumps([
["Opportunity", "creation", "Timespan", "last month"]
]),
"function": "Count",
"is_public": 1,
"label": _("New Opportunity (Last 1 Month)"),
"show_percentage_stats": 1,
"stats_time_interval": "Daily"
},
{
"doctype": "Number Card",
"document_type": "Opportunity",
"name": "Won Opportunity (Last 1 Month)",
"filters_json": json.dumps([
["Opportunity", "status", "=", "Converted",False],
["Opportunity", "creation", "Timespan", "last month"]
]),
"function": "Count",
"is_public": 1,
"label": _("Won Opportunity (Last 1 Month)"),
"show_percentage_stats": 1,
"stats_time_interval": "Daily"
},
{
"doctype": "Number Card",
"document_type": "Opportunity",
"name": "Open Opportunity",
"filters_json": json.dumps([["Opportunity","status","=","Open",False]]),
"function": "Count",
"is_public": 1,
"label": _("Open Opportunity"),
"show_percentage_stats": 1,
"stats_time_interval": "Daily"
}]

View File

@ -0,0 +1,21 @@
{
"creation": "2020-07-20 20:17:15.870736",
"docstatus": 0,
"doctype": "Number Card",
"document_type": "Lead",
"dynamic_filters_json": "[[\"Lead\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]",
"filters_json": "[[\"Lead\",\"creation\",\"Timespan\",\"last month\",false]]",
"function": "Count",
"idx": 0,
"is_public": 1,
"is_standard": 1,
"label": "New Lead (Last 1 Month)",
"modified": "2020-07-22 16:15:17.274972",
"modified_by": "Administrator",
"module": "CRM",
"name": "New Lead (Last 1 Month)",
"owner": "Administrator",
"show_percentage_stats": 1,
"stats_time_interval": "Daily",
"type": "Document Type"
}

View File

@ -0,0 +1,21 @@
{
"creation": "2020-07-20 20:17:15.897112",
"docstatus": 0,
"doctype": "Number Card",
"document_type": "Opportunity",
"dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]",
"filters_json": "[[\"Opportunity\",\"creation\",\"Timespan\",\"last month\",false]]",
"function": "Count",
"idx": 0,
"is_public": 1,
"is_standard": 1,
"label": "New Opportunity (Last 1 Month)",
"modified": "2020-07-22 16:07:27.910432",
"modified_by": "Administrator",
"module": "CRM",
"name": "New Opportunity (Last 1 Month)",
"owner": "Administrator",
"show_percentage_stats": 1,
"stats_time_interval": "Daily",
"type": "Document Type"
}

View File

@ -0,0 +1,21 @@
{
"creation": "2020-07-20 20:17:15.948113",
"docstatus": 0,
"doctype": "Number Card",
"document_type": "Opportunity",
"dynamic_filters_json": "[[\"Opportunity\",\"status\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]",
"filters_json": "[[\"Opportunity\",\"company\",\"=\",null,false]]",
"function": "Count",
"idx": 0,
"is_public": 1,
"is_standard": 1,
"label": "Open Opportunity",
"modified": "2020-07-22 16:16:16.420446",
"modified_by": "Administrator",
"module": "CRM",
"name": "Open Opportunity",
"owner": "Administrator",
"show_percentage_stats": 1,
"stats_time_interval": "Daily",
"type": "Document Type"
}

View File

@ -0,0 +1,21 @@
{
"creation": "2020-07-20 20:17:15.922486",
"docstatus": 0,
"doctype": "Number Card",
"document_type": "Opportunity",
"dynamic_filters_json": "[[\"Opportunity\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]",
"filters_json": "[[\"Opportunity\",\"creation\",\"Timespan\",\"last month\",false]]",
"function": "Count",
"idx": 0,
"is_public": 1,
"is_standard": 1,
"label": "Won Opportunity (Last 1 Month)",
"modified": "2020-07-22 16:15:53.088837",
"modified_by": "Administrator",
"module": "CRM",
"name": "Won Opportunity (Last 1 Month)",
"owner": "Administrator",
"show_percentage_stats": 1,
"stats_time_interval": "Daily",
"type": "Document Type"
}