From 548716675e23c80751c107c0ddbd9cea67257c16 Mon Sep 17 00:00:00 2001 From: GuillemCForgeFlow Date: Fri, 2 Jan 2026 11:54:09 +0100 Subject: [PATCH] [IMP]queue_job: only subscribe job creator if indicated via boolean method We add the `_subscribe_job_creator` method in `queue.job` which will return True for the cases where we want to subscribe the job creator, False otherwise. --- queue_job/models/queue_job.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/queue_job/models/queue_job.py b/queue_job/models/queue_job.py index 55ee7e526c..04ca44cf2a 100644 --- a/queue_job/models/queue_job.py +++ b/queue_job/models/queue_job.py @@ -350,8 +350,11 @@ def _message_post_on_failure(self): # at every job creation domain = self._subscribe_users_domain() base_users = self.env["res.users"].search(domain) + suscribe_job_creator = self._subscribe_job_creator() for record in self: - users = base_users | record.user_id + users = base_users + if suscribe_job_creator: + users |= record.user_id record.message_subscribe(partner_ids=users.mapped("partner_id").ids) msg = record._message_failed_job() if msg: @@ -368,6 +371,14 @@ def _subscribe_users_domain(self): domain.append(("company_id", "in", companies.ids)) return domain + @api.model + def _subscribe_job_creator(self): + """ + Whether the user that created the job should be subscribed to the job, + in addition to users determined by `_subscribe_users_domain` + """ + return True + def _message_failed_job(self): """Return a message which will be posted on the job when it is failed.