Skip to content

Commit

Permalink
fix: Closed status error in Work Order Summary (#28460)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
s-aga-r and ankush authored Nov 22, 2021
1 parent 3d0de59 commit aa68987
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
@@ -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 _
Expand Down Expand Up @@ -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"]

status_wise_data = {
"Not Started": 0,
"In Process": 0,
"Stopped": 0,
"Completed": 0,
"Draft": 0
}
labels = frappe.get_meta("Work Order").get_options("status").split("\n")
if "" in labels:
labels.remove("")

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": {
Expand Down

0 comments on commit aa68987

Please sign in to comment.