|
|
ticket_model = self.env["helpdesk.ticket"]
result = []
grouped_rows = ticket_model._read_group(
domain=[("team_id", "in", self.ids), ("closed", "=", False)],
groupby=["team_id", "user_id", "unattended", "priority"],
aggregates=["__count"],
)
for team, user, unattended, priority, count in grouped_rows:
result.append(
[
team.id if team else False,
user.id if user else False,
unattended,
priority,
count,
]
)
for team in self:
team.todo_ticket_count = sum(r[4] for r in result if r[0] == team.id)
team.todo_ticket_count_unassigned = sum(
r[4] for r in result if r[0] == team.id and not r[1]
)
team.todo_ticket_count_unattended = sum(
r[4] for r in result if r[0] == team.id and r[2]
)
team.todo_ticket_count_high_priority = sum(
r[4] for r in result if r[0] == team.id and r[3] == "3"
)
|
|