Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Job Queue Batch

Entity: queue.job.batch

Compute Method: _compute_job_count

Inputs Method Outputs
  • id
grouped = self.env["queue.job"].read_group(
            [("job_batch_id", "in", self.ids)],
            ["job_batch_id", "state"],
            ["job_batch_id", "state"],
            lazy=False,
        )
counts = {}
for g in grouped:
            batch_id = g["job_batch_id"][0]
            counts.setdefault(batch_id, {})
            counts[batch_id][g["state"]] = g["__count"]
for rec in self:
            by_state = counts.get(rec.id, {})
            total = sum(by_state.values())
            done = by_state.get("done", 0)
            failed = by_state.get("failed", 0)

            rec.job_count = total
            rec.failed_job_count = failed
            rec.finished_job_count = done
            rec.completeness = done / max(1, total)
            rec.failed_percentage = failed / max(1, total)

Back to entity