Skip to content

Commit 581278b

Browse files
author
Milan Topuzov
committed
models(queue_job): replace deprecated read_group with _read_group for graph job count\n\n- Align with Odoo 19 deprecation of read_group\n- Use _read_group([(graph_uuid,'in', ...)], ['graph_uuid'], ['__count'])\n- Maintain same behavior with default count 0
1 parent 34ad1fe commit 581278b

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

queue_job/models/queue_job.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -222,20 +222,18 @@ def _dependency_graph_vis_node(self):
222222
}
223223

224224
def _compute_graph_jobs_count(self):
225-
jobs_groups = self.env["queue.job"].read_group(
226-
[
227-
(
228-
"graph_uuid",
229-
"in",
230-
[uuid for uuid in self.mapped("graph_uuid") if uuid],
231-
)
232-
],
233-
["graph_uuid"],
234-
["graph_uuid"],
235-
)
236-
count_per_graph_uuid = {
237-
group["graph_uuid"]: group["graph_uuid_count"] for group in jobs_groups
238-
}
225+
# Use _read_group (read_group is deprecated in Odoo 19)
226+
graph_uuids = [uuid for uuid in self.mapped("graph_uuid") if uuid]
227+
if graph_uuids:
228+
rows = self.env["queue.job"]._read_group(
229+
[("graph_uuid", "in", graph_uuids)],
230+
["graph_uuid"],
231+
["__count"],
232+
)
233+
# rows are tuples of (graph_uuid, count)
234+
count_per_graph_uuid = {graph_uuid: cnt for graph_uuid, cnt in rows}
235+
else:
236+
count_per_graph_uuid = {}
239237
for record in self:
240238
record.graph_jobs_count = count_per_graph_uuid.get(record.graph_uuid) or 0
241239

0 commit comments

Comments
 (0)