Skip to content

Commit 43093b7

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 f308f58 commit 43093b7

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
@@ -354,8 +354,11 @@ def _message_post_on_failure(self):
354354
# at every job creation
355355
domain = self._subscribe_users_domain()
356356
base_users = self.env["res.users"].search(domain)
357+
suscribe_job_creator = self._subscribe_job_creator()
357358
for record in self:
358-
users = base_users | record.user_id
359+
users = base_users
360+
if suscribe_job_creator:
361+
users |= record.user_id
359362
record.message_subscribe(partner_ids=users.mapped("partner_id").ids)
360363
msg = record._message_failed_job()
361364
if msg:
@@ -372,6 +375,14 @@ def _subscribe_users_domain(self):
372375
domain.append(("company_id", "in", companies.ids))
373376
return domain
374377

378+
@api.model
379+
def _subscribe_job_creator(self):
380+
"""
381+
Whether the user that created the job should be subscribed to the job,
382+
in addition to users determined by `_subscribe_users_domain`
383+
"""
384+
return True
385+
375386
def _message_failed_job(self):
376387
"""Return a message which will be posted on the job when it is failed.
377388

0 commit comments

Comments
 (0)