From 84085d30650bf60b02bb32e7cac1faa346f04a9f Mon Sep 17 00:00:00 2001 From: Julien Ortet Date: Tue, 24 Mar 2026 15:29:24 +0100 Subject: [PATCH] [18][UPD] add empty batch remove when job vaccum --- queue_job_batch/models/queue_job.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/queue_job_batch/models/queue_job.py b/queue_job_batch/models/queue_job.py index ddc3efe879..c2b48bfcfe 100644 --- a/queue_job_batch/models/queue_job.py +++ b/queue_job_batch/models/queue_job.py @@ -30,3 +30,17 @@ def write(self, vals): # to work with the same batch batch.with_delay(identity_key=identity_exact).check_state() return super().write(vals) + + def autovacuum(self): + """Delete batches if all jobs are unlink after job autovacuum + Called from a cron. + """ + + ret = super().autovacuum() + batches = self.env["queue.job.batch"].search([("job_ids", "=", False)]) + + for batch in batches: + if not batch.job_ids: + batch.unlink() + + return ret