Skip to content

Commit 5487166

Browse files
[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.
1 parent c9e92aa commit 5487166

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

queue_job/models/queue_job.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,11 @@ def _message_post_on_failure(self):
350350
# at every job creation
351351
domain = self._subscribe_users_domain()
352352
base_users = self.env["res.users"].search(domain)
353+
suscribe_job_creator = self._subscribe_job_creator()
353354
for record in self:
354-
users = base_users | record.user_id
355+
users = base_users
356+
if suscribe_job_creator:
357+
users |= record.user_id
355358
record.message_subscribe(partner_ids=users.mapped("partner_id").ids)
356359
msg = record._message_failed_job()
357360
if msg:
@@ -368,6 +371,14 @@ def _subscribe_users_domain(self):
368371
domain.append(("company_id", "in", companies.ids))
369372
return domain
370373

374+
@api.model
375+
def _subscribe_job_creator(self):
376+
"""
377+
Whether the user that created the job should be subscribed to the job,
378+
in addition to users determined by `_subscribe_users_domain`
379+
"""
380+
return True
381+
371382
def _message_failed_job(self):
372383
"""Return a message which will be posted on the job when it is failed.
373384

0 commit comments

Comments
 (0)