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"),
|
label: __("Status"),
|
||||||
fieldname: "status",
|
fieldname: "status",
|
||||||
fieldtype: "Select",
|
fieldtype: "Select",
|
||||||
options: ["", "Not Started", "In Process", "Completed", "Stopped"]
|
options: ["", "Not Started", "In Process", "Completed", "Stopped", "Closed"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: __("Sales Orders"),
|
label: __("Sales Orders"),
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
|
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
@ -58,21 +59,16 @@ def get_chart_data(data, filters):
|
|||||||
return get_chart_based_on_qty(data, filters)
|
return get_chart_based_on_qty(data, filters)
|
||||||
|
|
||||||
def get_chart_based_on_status(data):
|
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 = {
|
status_wise_data = defaultdict(int)
|
||||||
"Not Started": 0,
|
|
||||||
"In Process": 0,
|
|
||||||
"Stopped": 0,
|
|
||||||
"Completed": 0,
|
|
||||||
"Draft": 0
|
|
||||||
}
|
|
||||||
|
|
||||||
for d in data:
|
for d in data:
|
||||||
status_wise_data[d.status] += 1
|
status_wise_data[d.status] += 1
|
||||||
|
|
||||||
values = [status_wise_data["Completed"], status_wise_data["In Process"],
|
values = [status_wise_data[label] for label in labels]
|
||||||
status_wise_data["Stopped"], status_wise_data["Not Started"]]
|
|
||||||
|
|
||||||
chart = {
|
chart = {
|
||||||
"data": {
|
"data": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user