Rohit Waghchaure
5 years ago
19 changed files with 545 additions and 296 deletions
@ -0,0 +1,216 @@ |
|||
# 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 [{ |
|||
"name": "Manufacturing Dashboard", |
|||
"dashboard_name": "Manufacturing Dashboard", |
|||
"charts": [ |
|||
{ "chart": "Produced Quantity", "width": "Half" }, |
|||
{ "chart": "Completed Operation", "width": "Half" }, |
|||
{ "chart": "Work Order Analysis", "width": "Half" }, |
|||
{ "chart": "Quality Inspection Analysis", "width": "Half" }, |
|||
{ "chart": "Pending Work Order", "width": "Half" }, |
|||
{ "chart": "Last Month Downtime Analysis", "width": "Half" }, |
|||
{ "chart": "Work Order Qty Analysis", "width": "Full" }, |
|||
{ "chart": "Job Card Analysis", "width": "Full" } |
|||
], |
|||
"cards": [ |
|||
{ "card": "Total Work Order" }, |
|||
{ "card": "Completed Work Order" }, |
|||
{ "card": "Ongoing Job Card" }, |
|||
{ "card": "Total Quality Inspection"} |
|||
] |
|||
}] |
|||
|
|||
def get_charts(): |
|||
company = erpnext.get_default_company() |
|||
|
|||
if not company: |
|||
company = frappe.db.get_value("Company", {"is_group": 0}, "name") |
|||
|
|||
return [{ |
|||
"doctype": "Dashboard Chart", |
|||
"based_on": "creation", |
|||
"time_interval": "Yearly", |
|||
"chart_type": "Sum", |
|||
"chart_name": "Produced Quantity", |
|||
"document_type": "Work Order", |
|||
"filters_json": json.dumps({}), |
|||
"group_by_type": "Count", |
|||
"time_interval": "Quarterly", |
|||
"timespan": "Last Year", |
|||
"owner": "Administrator", |
|||
"type": "Line", |
|||
"value_based_on": "qty", |
|||
"is_public": 1, |
|||
"timeseries": 1 |
|||
}, { |
|||
"doctype": "Dashboard Chart", |
|||
"based_on": "creation", |
|||
"time_interval": "Yearly", |
|||
"chart_type": "Sum", |
|||
"chart_name": "Completed Operation", |
|||
"document_type": "Work Order Operation", |
|||
"filters_json": json.dumps({}), |
|||
"group_by_type": "Count", |
|||
"time_interval": "Quarterly", |
|||
"timespan": "Last Year", |
|||
"owner": "Administrator", |
|||
"type": "Line", |
|||
"value_based_on": "completed_qty", |
|||
"is_public": 1, |
|||
"timeseries": 1 |
|||
}, { |
|||
"doctype": "Dashboard Chart", |
|||
"time_interval": "Yearly", |
|||
"chart_type": "Report", |
|||
"chart_name": "Work Order Analysis", |
|||
"timespan": "Last Year", |
|||
"report_name": "Work Order Summary", |
|||
"owner": "Administrator", |
|||
"filters_json": json.dumps({"company": company, "charts_based_on": "Status"}), |
|||
"type": "Donut", |
|||
"is_public": 1, |
|||
"is_custom": 1, |
|||
"custom_options": json.dumps({ |
|||
"axisOptions": { |
|||
"shortenYAxisNumbers": 1 |
|||
}, |
|||
"height": 300 |
|||
}), |
|||
}, { |
|||
"doctype": "Dashboard Chart", |
|||
"time_interval": "Yearly", |
|||
"chart_type": "Report", |
|||
"chart_name": "Quality Inspection Analysis", |
|||
"timespan": "Last Year", |
|||
"report_name": "Quality Inspection Summary", |
|||
"owner": "Administrator", |
|||
"filters_json": json.dumps({}), |
|||
"type": "Donut", |
|||
"is_public": 1, |
|||
"is_custom": 1, |
|||
"custom_options": json.dumps({ |
|||
"axisOptions": { |
|||
"shortenYAxisNumbers": 1 |
|||
}, |
|||
"height": 300 |
|||
}), |
|||
}, { |
|||
"doctype": "Dashboard Chart", |
|||
"time_interval": "Yearly", |
|||
"chart_type": "Report", |
|||
"chart_name": "Pending Work Order", |
|||
"timespan": "Last Year", |
|||
"report_name": "Work Order Summary", |
|||
"filters_json": json.dumps({"company": company, "charts_based_on": "Age"}), |
|||
"owner": "Administrator", |
|||
"type": "Donut", |
|||
"is_public": 1, |
|||
"is_custom": 1, |
|||
"custom_options": json.dumps({ |
|||
"axisOptions": { |
|||
"shortenYAxisNumbers": 1 |
|||
}, |
|||
"height": 300 |
|||
}), |
|||
}, { |
|||
"doctype": "Dashboard Chart", |
|||
"time_interval": "Yearly", |
|||
"chart_type": "Report", |
|||
"chart_name": "Last Month Downtime Analysis", |
|||
"timespan": "Last Year", |
|||
"filters_json": json.dumps({}), |
|||
"report_name": "Downtime Analysis", |
|||
"owner": "Administrator", |
|||
"is_public": 1, |
|||
"is_custom": 1, |
|||
"type": "Bar" |
|||
}, { |
|||
"doctype": "Dashboard Chart", |
|||
"time_interval": "Yearly", |
|||
"chart_type": "Report", |
|||
"chart_name": _("Work Order Qty Analysis"), |
|||
"timespan": "Last Year", |
|||
"report_name": "Work Order Summary", |
|||
"filters_json": json.dumps({"company": company, "charts_based_on": "Quantity"}), |
|||
"owner": "Administrator", |
|||
"type": "Bar", |
|||
"is_public": 1, |
|||
"is_custom": 1, |
|||
"custom_options": json.dumps({ |
|||
"barOptions": { "stacked": 1 } |
|||
}), |
|||
}, { |
|||
"doctype": "Dashboard Chart", |
|||
"time_interval": "Yearly", |
|||
"chart_type": "Report", |
|||
"chart_name": "Job Card Analysis", |
|||
"timespan": "Last Year", |
|||
"report_name": "Job Card Summary", |
|||
"owner": "Administrator", |
|||
"is_public": 1, |
|||
"is_custom": 1, |
|||
"filters_json": json.dumps({"company": company, "range":"Monthly"}), |
|||
"custom_options": json.dumps({ |
|||
"barOptions": { "stacked": 1 } |
|||
}), |
|||
"type": "Bar" |
|||
}] |
|||
|
|||
def get_number_cards(): |
|||
return [{ |
|||
"doctype": "Number Card", |
|||
"document_type": "Work Order", |
|||
"name": "Total Work Order", |
|||
"filters_json": json.dumps([]), |
|||
"function": "Count", |
|||
"is_public": 1, |
|||
"label": _("Total Work Order"), |
|||
"show_percentage_stats": 1, |
|||
"stats_time_interval": "Daily" |
|||
}, |
|||
{ |
|||
"doctype": "Number Card", |
|||
"document_type": "Work Order", |
|||
"name": "Completed Work Order", |
|||
"filters_json": json.dumps([['Work Order', 'status','=','Completed', False]]), |
|||
"function": "Count", |
|||
"is_public": 1, |
|||
"label": _("Completed Work Order"), |
|||
"show_percentage_stats": 1, |
|||
"stats_time_interval": "Daily" |
|||
}, |
|||
{ |
|||
"doctype": "Number Card", |
|||
"document_type": "Job Card", |
|||
"name": "Ongoing Job Card", |
|||
"filters_json": json.dumps([['Job Card', 'status','!=','Completed', False]]), |
|||
"function": "Count", |
|||
"is_public": 1, |
|||
"label": _("Ongoing Job Card"), |
|||
"show_percentage_stats": 1, |
|||
"stats_time_interval": "Daily" |
|||
}, |
|||
{ |
|||
"doctype": "Number Card", |
|||
"document_type": "Quality Inspection", |
|||
"name": "Total Quality Inspection", |
|||
"filters_json": json.dumps([]), |
|||
"function": "Count", |
|||
"is_public": 1, |
|||
"label": _("Total Quality Inspection"), |
|||
"show_percentage_stats": 1, |
|||
"stats_time_interval": "Daily" |
|||
}] |
@ -0,0 +1,54 @@ |
|||
{ |
|||
"allow_roles": [ |
|||
{ |
|||
"role": "Manufacturing User" |
|||
}, |
|||
{ |
|||
"role": "Manufacturing Manager" |
|||
}, |
|||
{ |
|||
"role": "Item Manager" |
|||
}, |
|||
{ |
|||
"role": "Stock User" |
|||
} |
|||
], |
|||
"creation": "2020-05-05 16:37:08.238935", |
|||
"docstatus": 0, |
|||
"doctype": "Onboarding", |
|||
"documentation_url": "https://docs.erpnext.com/docs/user/manual/en/manufacturing", |
|||
"idx": 0, |
|||
"is_complete": 0, |
|||
"modified": "2020-05-12 16:22:07.050224", |
|||
"modified_by": "Administrator", |
|||
"module": "Manufacturing", |
|||
"name": "Manufacturing", |
|||
"owner": "Administrator", |
|||
"steps": [ |
|||
{ |
|||
"step": "Introduction to Manufacturing" |
|||
}, |
|||
{ |
|||
"step": "Warehouse" |
|||
}, |
|||
{ |
|||
"step": "Workstation" |
|||
}, |
|||
{ |
|||
"step": "Operation" |
|||
}, |
|||
{ |
|||
"step": "Create Product" |
|||
}, |
|||
{ |
|||
"step": "Create BOM" |
|||
}, |
|||
{ |
|||
"step": "Work Order" |
|||
} |
|||
], |
|||
"subtitle": "Products, Raw Materials, BOM, Work Order and more.", |
|||
"success_message": "Manufacturing module is all setup!", |
|||
"title": "Let's Setup Manufacturing Module", |
|||
"user_can_dismiss": 1 |
|||
} |
@ -0,0 +1,16 @@ |
|||
{ |
|||
"action": "Create Entry", |
|||
"creation": "2020-05-05 16:41:20.239696", |
|||
"docstatus": 0, |
|||
"doctype": "Onboarding Step", |
|||
"idx": 0, |
|||
"is_complete": 0, |
|||
"is_mandatory": 1, |
|||
"is_skipped": 0, |
|||
"modified": "2020-05-05 16:41:20.239696", |
|||
"modified_by": "Administrator", |
|||
"name": "Create BOM", |
|||
"owner": "Administrator", |
|||
"reference_document": "BOM", |
|||
"title": "Create BOM" |
|||
} |
@ -0,0 +1,16 @@ |
|||
{ |
|||
"action": "Create Entry", |
|||
"creation": "2020-05-05 16:42:31.476275", |
|||
"docstatus": 0, |
|||
"doctype": "Onboarding Step", |
|||
"idx": 0, |
|||
"is_complete": 0, |
|||
"is_mandatory": 1, |
|||
"is_skipped": 0, |
|||
"modified": "2020-05-05 16:42:31.476275", |
|||
"modified_by": "Administrator", |
|||
"name": "Create Product", |
|||
"owner": "Administrator", |
|||
"reference_document": "Item", |
|||
"title": "Create Product" |
|||
} |
@ -0,0 +1,17 @@ |
|||
{ |
|||
"action": "Update Settings", |
|||
"creation": "2020-05-05 16:40:23.676406", |
|||
"docstatus": 0, |
|||
"doctype": "Onboarding Step", |
|||
"idx": 0, |
|||
"is_complete": 0, |
|||
"is_mandatory": 0, |
|||
"is_skipped": 0, |
|||
"modified": "2020-05-05 16:40:23.676406", |
|||
"modified_by": "Administrator", |
|||
"name": "Introduction to Manufacturing", |
|||
"owner": "Administrator", |
|||
"reference_document": "Manufacturing Settings", |
|||
"title": "Manufacturing Settings", |
|||
"video_url": "https://www.youtube.com/watch?v=UVGfzwOOZC4" |
|||
} |
@ -0,0 +1,15 @@ |
|||
{ |
|||
"action": "Create Entry", |
|||
"creation": "2020-05-12 16:15:31.706756", |
|||
"docstatus": 0, |
|||
"doctype": "Onboarding Step", |
|||
"idx": 0, |
|||
"is_complete": 0, |
|||
"is_mandatory": 0, |
|||
"is_skipped": 0, |
|||
"modified": "2020-05-12 16:17:06.943067", |
|||
"modified_by": "Administrator", |
|||
"name": "Operation", |
|||
"owner": "Administrator", |
|||
"title": "Create Operation" |
|||
} |
@ -0,0 +1,15 @@ |
|||
{ |
|||
"action": "Create Entry", |
|||
"creation": "2020-05-12 16:13:34.014554", |
|||
"docstatus": 0, |
|||
"doctype": "Onboarding Step", |
|||
"idx": 0, |
|||
"is_complete": 0, |
|||
"is_mandatory": 0, |
|||
"is_skipped": 0, |
|||
"modified": "2020-05-12 16:16:48.345846", |
|||
"modified_by": "Administrator", |
|||
"name": "Warehouse", |
|||
"owner": "Administrator", |
|||
"title": "Create Warehouse" |
|||
} |
@ -0,0 +1,15 @@ |
|||
{ |
|||
"action": "Create Entry", |
|||
"creation": "2020-05-12 16:15:56.084682", |
|||
"docstatus": 0, |
|||
"doctype": "Onboarding Step", |
|||
"idx": 0, |
|||
"is_complete": 0, |
|||
"is_mandatory": 0, |
|||
"is_skipped": 0, |
|||
"modified": "2020-05-12 16:17:33.675304", |
|||
"modified_by": "Administrator", |
|||
"name": "Work Order", |
|||
"owner": "Administrator", |
|||
"title": "Create Work Order" |
|||
} |
@ -0,0 +1,15 @@ |
|||
{ |
|||
"action": "Create Entry", |
|||
"creation": "2020-05-12 16:14:14.930214", |
|||
"docstatus": 0, |
|||
"doctype": "Onboarding Step", |
|||
"idx": 0, |
|||
"is_complete": 0, |
|||
"is_mandatory": 0, |
|||
"is_skipped": 0, |
|||
"modified": "2020-05-12 16:16:58.808906", |
|||
"modified_by": "Administrator", |
|||
"name": "Workstation", |
|||
"owner": "Administrator", |
|||
"title": "Create Workstation" |
|||
} |
@ -1,247 +0,0 @@ |
|||
from __future__ import unicode_literals |
|||
from frappe import _ |
|||
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_default_dashboards(): |
|||
company = frappe.get_doc("Company", get_company_for_dashboards()) |
|||
income_account = company.default_income_account or get_account("Income Account", company.name) |
|||
expense_account = company.default_expense_account or get_account("Expense Account", company.name) |
|||
bank_account = company.default_bank_account or get_account("Bank", company.name) |
|||
|
|||
return { |
|||
"Dashboards": [ |
|||
{ |
|||
"doctype": "Dashboard", |
|||
"dashboard_name": "Accounts", |
|||
"charts": [ |
|||
{ "chart": "Outgoing Bills (Sales Invoice)" }, |
|||
{ "chart": "Incoming Bills (Purchase Invoice)" }, |
|||
{ "chart": "Bank Balance" }, |
|||
{ "chart": "Income" }, |
|||
{ "chart": "Expenses" }, |
|||
{ "chart": "Patient Appointments" } |
|||
] |
|||
}, |
|||
{ |
|||
"doctype": "Dashboard", |
|||
"dashboard_name": "Manufacturing", |
|||
"charts": [ |
|||
{ "chart": "Work Order Analysis", "width": "Half" }, |
|||
{ "chart": "Quality Inspection Analysis", "width": "Half" }, |
|||
{ "chart": "Long Time Pending Work Orders", "width": "Half" }, |
|||
{ "chart": "Downtime Analysis", "width": "Half" }, |
|||
{ "chart": "Production Analysis", "width": "Full" }, |
|||
{ "chart": "Job Card Analysis", "width": "Full" } |
|||
] |
|||
} |
|||
], |
|||
"Charts": [ |
|||
{ |
|||
"doctype": "Dashboard Chart", |
|||
"time_interval": "Quarterly", |
|||
"chart_name": "Income", |
|||
"timespan": "Last Year", |
|||
"color": None, |
|||
"filters_json": json.dumps({"company": company.name, "account": income_account}), |
|||
"source": "Account Balance Timeline", |
|||
"chart_type": "Custom", |
|||
"timeseries": 1, |
|||
"owner": "Administrator", |
|||
"type": "Line", |
|||
"width": "Half" |
|||
}, |
|||
{ |
|||
"doctype": "Dashboard Chart", |
|||
"time_interval": "Quarterly", |
|||
"chart_name": "Expenses", |
|||
"timespan": "Last Year", |
|||
"color": None, |
|||
"filters_json": json.dumps({"company": company.name, "account": expense_account}), |
|||
"source": "Account Balance Timeline", |
|||
"chart_type": "Custom", |
|||
"timeseries": 1, |
|||
"owner": "Administrator", |
|||
"type": "Line", |
|||
"width": "Half" |
|||
}, |
|||
{ |
|||
"doctype": "Dashboard Chart", |
|||
"time_interval": "Quarterly", |
|||
"chart_name": "Bank Balance", |
|||
"timespan": "Last Year", |
|||
"color": "#ffb868", |
|||
"filters_json": json.dumps({"company": company.name, "account": bank_account}), |
|||
"source": "Account Balance Timeline", |
|||
"chart_type": "Custom", |
|||
"timeseries": 1, |
|||
"owner": "Administrator", |
|||
"type": "Line", |
|||
"width": "Half" |
|||
}, |
|||
{ |
|||
"doctype": "Dashboard Chart", |
|||
"time_interval": "Monthly", |
|||
"chart_name": "Incoming Bills (Purchase Invoice)", |
|||
"timespan": "Last Year", |
|||
"color": "#a83333", |
|||
"value_based_on": "base_grand_total", |
|||
"filters_json": json.dumps({}), |
|||
"chart_type": "Sum", |
|||
"timeseries": 1, |
|||
"based_on": "posting_date", |
|||
"owner": "Administrator", |
|||
"document_type": "Purchase Invoice", |
|||
"type": "Bar", |
|||
"width": "Half" |
|||
}, |
|||
{ |
|||
"doctype": "Dashboard Chart", |
|||
"time_interval": "Monthly", |
|||
"chart_name": "Outgoing Bills (Sales Invoice)", |
|||
"timespan": "Last Year", |
|||
"color": "#7b933d", |
|||
"value_based_on": "base_grand_total", |
|||
"filters_json": json.dumps({}), |
|||
"chart_type": "Sum", |
|||
"timeseries": 1, |
|||
"based_on": "posting_date", |
|||
"owner": "Administrator", |
|||
"document_type": "Sales Invoice", |
|||
"type": "Bar", |
|||
"width": "Half" |
|||
}, |
|||
{ |
|||
"doctype": "Dashboard Chart", |
|||
"time_interval": "Daily", |
|||
"chart_name": "Patient Appointments", |
|||
"timespan": "Last Month", |
|||
"color": "#77ecca", |
|||
"filters_json": json.dumps({}), |
|||
"chart_type": "Count", |
|||
"timeseries": 1, |
|||
"based_on": "appointment_datetime", |
|||
"owner": "Administrator", |
|||
"document_type": "Patient Appointment", |
|||
"type": "Line", |
|||
"width": "Half" |
|||
} |
|||
{ |
|||
"doctype": "Dashboard Chart", |
|||
"time_interval": "Yearly", |
|||
"chart_type": "Report", |
|||
"chart_name": "Work Order Analysis", |
|||
"timespan": "Last Year", |
|||
"report_name": "Work Order Summary", |
|||
"owner": "Administrator", |
|||
"filters_json": json.dumps({"company": company.name}), |
|||
"bar": "Donut", |
|||
"custom_options": json.dumps({ |
|||
"axisOptions": { |
|||
"shortenYAxisNumbers": 1 |
|||
}, |
|||
"height": 300, |
|||
"colors": ["#ff5858", "#ffa00a", "#5e64ff", "#98d85b"] |
|||
}), |
|||
}, |
|||
{ |
|||
"doctype": "Dashboard Chart", |
|||
"time_interval": "Yearly", |
|||
"chart_type": "Report", |
|||
"chart_name": "Quality Inspection Analysis", |
|||
"timespan": "Last Year", |
|||
"report_name": "Quality Inspection Summary", |
|||
"owner": "Administrator", |
|||
"filters_json": json.dumps({}), |
|||
"bar": "Donut", |
|||
"custom_options": json.dumps({ |
|||
"axisOptions": { |
|||
"shortenYAxisNumbers": 1 |
|||
}, |
|||
"height": 300, |
|||
"colors": ["#ff5858", "#98d85b"] |
|||
}), |
|||
}, |
|||
{ |
|||
"doctype": "Dashboard Chart", |
|||
"time_interval": "Yearly", |
|||
"chart_type": "Report", |
|||
"chart_name": "Long Time Pending Work Orders", |
|||
"timespan": "Last Year", |
|||
"report_name": "Work Order Summary", |
|||
"filters_json": json.dumps({"company": company.name, "age":180}), |
|||
"owner": "Administrator", |
|||
"bar": "Bar", |
|||
"custom_options": json.dumps({ |
|||
"colors": ["#ff5858"], |
|||
"x_field": "name", |
|||
"y_fields": ["age"], |
|||
"y_axis_fields": [{"__islocal": "true", "idx": 1, "y_field": "age"}], |
|||
"chart_type": "Bar" |
|||
}), |
|||
}, |
|||
{ |
|||
"doctype": "Dashboard Chart", |
|||
"time_interval": "Yearly", |
|||
"chart_type": "Report", |
|||
"chart_name": "Downtime Analysis", |
|||
"timespan": "Last Year", |
|||
"filters_json": json.dumps({}), |
|||
"report_name": "Downtime Analysis", |
|||
"owner": "Administrator", |
|||
"bar": "Bar", |
|||
"custom_options": json.dumps({ |
|||
"colors": ["#ff5858"] |
|||
}), |
|||
}, |
|||
{ |
|||
"doctype": "Dashboard Chart", |
|||
"time_interval": "Yearly", |
|||
"chart_type": "Report", |
|||
"chart_name": "Production Analysis", |
|||
"timespan": "Last Year", |
|||
"report_name": "Production Analytics", |
|||
"owner": "Administrator", |
|||
"filters_json": json.dumps({"company": company.name, "range":"Monthly"}), |
|||
"bar": "Bar", |
|||
"custom_options": json.dumps({ |
|||
"colors": ["#7cd6fd", "#ff5858", "#ffa00a", "#98d85b"] |
|||
}), |
|||
}, |
|||
{ |
|||
"doctype": "Dashboard Chart", |
|||
"time_interval": "Yearly", |
|||
"chart_type": "Report", |
|||
"chart_name": "Job Card Analysis", |
|||
"timespan": "Last Year", |
|||
"report_name": "Job Card Summary", |
|||
"owner": "Administrator", |
|||
"filters_json": json.dumps({"company": company.name, "range":"Monthly"}), |
|||
"bar": "Bar", |
|||
"custom_options": json.dumps({ |
|||
"axisOptions": { |
|||
"xAxisMode": "tick" |
|||
}, |
|||
"barOptions": { |
|||
"stacked": 1 |
|||
}, |
|||
"colors": ["#ff5858", "#ffa00a", "#5e64ff", "#98d85b"] |
|||
}), |
|||
}, |
|||
] |
|||
} |
|||
|
|||
def get_account(account_type, company): |
|||
accounts = frappe.get_list("Account", filters={"account_type": account_type, "company": company}) |
|||
if accounts: |
|||
return accounts[0].name |
Loading…
Reference in new issue