Skip to content

Commit 0ca06a9

Browse files
GuillemCForgeFlowguewen
authored andcommitted
[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 7f591be commit 0ca06a9

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

queue_job/models/queue_job.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,11 @@ def _message_post_on_failure(self):
358358
# at every job creation
359359
domain = self._subscribe_users_domain()
360360
base_users = self.env["res.users"].search(domain)
361+
suscribe_job_creator = self._subscribe_job_creator()
361362
for record in self:
362-
users = base_users | record.user_id
363+
users = base_users
364+
if suscribe_job_creator:
365+
users |= record.user_id
363366
record.message_subscribe(partner_ids=users.mapped("partner_id").ids)
364367
msg = record._message_failed_job()
365368
if msg:
@@ -376,6 +379,14 @@ def _subscribe_users_domain(self):
376379
domain.append(("company_id", "in", companies.ids))
377380
return domain
378381

382+
@api.model
383+
def _subscribe_job_creator(self):
384+
"""
385+
Whether the user that created the job should be subscribed to the job,
386+
in addition to users determined by `_subscribe_users_domain`
387+
"""
388+
return True
389+
379390
def _message_failed_job(self):
380391
"""Return a message which will be posted on the job when it is failed.
381392

0 commit comments

Comments
 (0)