mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-22 22:49:19 +00:00
feat: add fixture for project dashboards
This commit is contained in:
48
erpnext/projects/dashboard_fixtures.py
Normal file
48
erpnext/projects/dashboard_fixtures.py
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
import json
|
||||||
|
|
||||||
|
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_data():
|
||||||
|
return frappe._dict({
|
||||||
|
"dashboards": get_dashboards(),
|
||||||
|
"charts": get_charts(),
|
||||||
|
})
|
||||||
|
|
||||||
|
def get_dashboards():
|
||||||
|
return [{
|
||||||
|
"doctype": "Dashboard",
|
||||||
|
"name": "Project",
|
||||||
|
"dashboard_name": "Project",
|
||||||
|
"charts": [
|
||||||
|
{ "chart": "Project Summary", "width": "Full" }
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
|
||||||
|
def get_charts():
|
||||||
|
company = frappe.get_doc("Company", get_company_for_dashboards())
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
'doctype': 'Dashboard Chart',
|
||||||
|
'name': 'Project Summary',
|
||||||
|
'chart_name': 'Project Summary',
|
||||||
|
'chart_type': 'Report',
|
||||||
|
'report_name': 'Project Summary',
|
||||||
|
'is_public': 1,
|
||||||
|
'filters_json': json.dumps({"company": company.name, "status": "Open"}),
|
||||||
|
'type': 'Bar',
|
||||||
|
'custom_options': '{"type": "bar", "colors": ["#fc4f51", "#78d6ff", "#7575ff"], "axisOptions": { "shortenYAxisNumbers": 1}, "barOptions": { "stacked": 1 }}',
|
||||||
|
}
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user