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:
parent
3d0de59131
commit
aa689874e3
@ -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"),
|
||||
|
@ -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": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user