fix: Closed status error in Work Order Summary (#28460)

* fix: Closed status error in Work Order Summary

* chore: use get_meta to get status options

* refactor: simplify code

Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
Sagar Sharma 2021-11-22 13:06:59 +05:30 committed by GitHub
parent 3d0de59131
commit aa689874e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 11 deletions

View File

@ -51,7 +51,7 @@ frappe.query_reports["Work Order Summary"] = {
label: __("Status"),
fieldname: "status",
fieldtype: "Select",
options: ["", "Not Started", "In Process", "Completed", "Stopped"]
options: ["", "Not Started", "In Process", "Completed", "Stopped", "Closed"]
},
{
label: __("Sales Orders"),

View File

@ -1,6 +1,7 @@
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from collections import defaultdict
import frappe
from frappe import _
@ -58,21 +59,16 @@ def get_chart_data(data, filters):
return get_chart_based_on_qty(data, filters)
def get_chart_based_on_status(data):
labels = ["Completed", "In Process", "Stopped", "Not Started"]
labels = frappe.get_meta("Work Order").get_options("status").split("\n")
if "" in labels:
labels.remove("")
status_wise_data = {
"Not Started": 0,
"In Process": 0,
"Stopped": 0,
"Completed": 0,
"Draft": 0
}
status_wise_data = defaultdict(int)
for d in data:
status_wise_data[d.status] += 1
values = [status_wise_data["Completed"], status_wise_data["In Process"],
status_wise_data["Stopped"], status_wise_data["Not Started"]]
values = [status_wise_data[label] for label in labels]
chart = {
"data": {