Commit 4f30f0e8 authored by Jérome Perrin's avatar Jérome Perrin

officejs_support_request_ui: workaround when we don't have a SR in each state

parent c3304c6f
...@@ -16,6 +16,7 @@ date_30_midnight = DateTime(now_date - timedelta(days=30)).earliestTime() ...@@ -16,6 +16,7 @@ date_30_midnight = DateTime(now_date - timedelta(days=30)).earliestTime()
# currently active support requests by state. Unless CRM agents are late # currently active support requests by state. Unless CRM agents are late
# in the processing of these support requests, they should not be too many. # in the processing of these support requests, they should not be too many.
count_by_state_and_date_range = defaultdict(lambda:defaultdict(int)) count_by_state_and_date_range = defaultdict(lambda:defaultdict(int))
for brain in portal.portal_catalog( for brain in portal.portal_catalog(
portal_type="Support Request", portal_type="Support Request",
simulation_state=("submitted", "suspended", "validated",), simulation_state=("submitted", "suspended", "validated",),
...@@ -49,6 +50,14 @@ count_by_state_and_date_range = { ...@@ -49,6 +50,14 @@ count_by_state_and_date_range = {
for date_range in date_range_list ] for date_range in date_range_list ]
} for state in count_by_state_and_date_range } } for state in count_by_state_and_date_range }
# XXX
state_title_by_state_id = portal.ERP5Site_getTicketWorkflowStateInfoDict()
for c in state_title_by_state_id.keys():
if c not in count_by_state_and_date_range:
count_by_state_and_date_range[c] = {
"date_range_list": date_range_list,
"count_list": [0, 0, 0, 0],
}
# Count last month activity by state # Count last month activity by state
# we only select support requests from last 30 days, so there should not be too many. # we only select support requests from last 30 days, so there should not be too many.
...@@ -66,3 +75,4 @@ return dumps({ ...@@ -66,3 +75,4 @@ return dumps({
"count_by_state_and_date_range": count_by_state_and_date_range, "count_by_state_and_date_range": count_by_state_and_date_range,
"state_title_by_state_id": portal.ERP5Site_getTicketWorkflowStateInfoDict() "state_title_by_state_id": portal.ERP5Site_getTicketWorkflowStateInfoDict()
}) })
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment