feat(fusion_helpdesk): group My Tickets into Critical/New/Solved sections
The flat write_date-sorted list was hard to scan with 50+ tickets — solved ones were intermixed with active ones, and there was no signal for priority. Bucket each ticket server-side into 'critical' (open + priority High/Urgent), 'solved' (stage marked fold=True on central) or 'open' (everything else), and render three labelled sections in the dialog with sticky headers, count badges, and per-group accent colours. Backend keeps its write_date desc order so latest is always at top within each bucket. Bucketing uses helpdesk.stage.fold (not the stage name) so renaming "Solved" to "Done" on the central won't quietly mis-categorise rows. Adds bucket_ticket() in utils.py with unit tests covering the folded-wins-over-priority precedence and the missing-priority fallback. Also surfaces a small Urgent (triangle) / High (arrow) icon on each row so a critical ticket reads at a glance even after a user scrolls past the section header. Bumps fusion_helpdesk to 19.0.1.6.0.
This commit is contained in:
@@ -26,6 +26,7 @@ from odoo.http import request
|
||||
from odoo.addons.fusion_helpdesk.utils import (
|
||||
build_ticket_vals,
|
||||
build_scope_domain,
|
||||
bucket_ticket,
|
||||
is_public_message,
|
||||
compute_unread_count,
|
||||
escape_like,
|
||||
@@ -418,6 +419,21 @@ class FusionHelpdeskController(http.Controller):
|
||||
'again in a moment.') % {'code': e.errcode},
|
||||
)
|
||||
|
||||
def _stage_fold_map(self, cfg, tickets):
|
||||
"""{stage_id: fold_bool} for the distinct stages on these tickets.
|
||||
|
||||
`helpdesk.stage.fold` is the central support team's signal for
|
||||
"kanban-folded = closed" — Solved + Cancelled by default. We use it
|
||||
(not the stage name) to bucket tickets into the Solved section, so
|
||||
renaming a stage on central doesn't quietly mis-categorise rows.
|
||||
One extra RPC per list call, batched across all distinct stages."""
|
||||
ids = sorted({t['stage_id'][0] for t in tickets if t.get('stage_id')})
|
||||
if not ids:
|
||||
return {}
|
||||
rows = self._rpc(cfg, 'helpdesk.stage', 'read',
|
||||
[ids], {'fields': ['fold']})
|
||||
return {r['id']: r.get('fold', False) for r in rows}
|
||||
|
||||
def _internal_subtype_map(self, cfg, subtype_ids):
|
||||
"""{subtype_id: internal_bool} so internal notes can be hidden."""
|
||||
ids = [s for s in set(subtype_ids) if s]
|
||||
@@ -562,9 +578,10 @@ class FusionHelpdeskController(http.Controller):
|
||||
tickets = self._rpc(
|
||||
cfg, 'helpdesk.ticket', 'search_read', [domain],
|
||||
{'fields': ['id', 'name', 'stage_id', 'partner_id',
|
||||
'write_date', 'ticket_ref'],
|
||||
'write_date', 'ticket_ref', 'priority'],
|
||||
'order': 'write_date desc', 'limit': 100})
|
||||
msgs = self._ticket_messages(cfg, [t['id'] for t in tickets])
|
||||
stage_fold = self._stage_fold_map(cfg, tickets)
|
||||
except (_RemoteError, xmlrpc.client.Fault, OSError, ssl.SSLError) as e:
|
||||
return self._remote_failure(cfg, e)
|
||||
|
||||
@@ -575,6 +592,7 @@ class FusionHelpdeskController(http.Controller):
|
||||
for t in tickets:
|
||||
rid = t['id']
|
||||
ls = last_support.get(rid, 0)
|
||||
sid = t['stage_id'][0] if t['stage_id'] else None
|
||||
rows.append({
|
||||
'id': rid,
|
||||
'ref': t.get('ticket_ref') or str(rid),
|
||||
@@ -583,6 +601,9 @@ class FusionHelpdeskController(http.Controller):
|
||||
'last_update': t['write_date'],
|
||||
'last_support_msg_id': ls,
|
||||
'has_unread': ls > (seen.get(rid, 0) or 0),
|
||||
'priority': t.get('priority') or '0',
|
||||
'group': bucket_ticket(stage_fold.get(sid, False),
|
||||
t.get('priority')),
|
||||
})
|
||||
return {'ok': True, 'tickets': rows, 'is_admin': ident['is_admin'],
|
||||
'unread': compute_unread_count(rows, seen)}
|
||||
|
||||
Reference in New Issue
Block a user