Skip to content

Commit f35df77

Browse files
[IMP]queue_job: hook for users to notify on job failure
Get the users to notify on failure with a hook so it can be inherited and adjusted if needed
1 parent c9e92aa commit f35df77

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

queue_job/models/queue_job.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,9 @@ def _message_post_on_failure(self):
349349
# subscribe the users now to avoid to subscribe them
350350
# at every job creation
351351
domain = self._subscribe_users_domain()
352-
base_users = self.env["res.users"].search(domain)
352+
manager_group_users = self.env["res.users"].search(domain)
353353
for record in self:
354-
users = base_users | record.user_id
354+
users = record._get_users_to_notify_on_failure(manager_group_users)
355355
record.message_subscribe(partner_ids=users.mapped("partner_id").ids)
356356
msg = record._message_failed_job()
357357
if msg:
@@ -368,6 +368,10 @@ def _subscribe_users_domain(self):
368368
domain.append(("company_id", "in", companies.ids))
369369
return domain
370370

371+
def _get_users_to_notify_on_failure(self, base_users):
372+
self.ensure_one()
373+
return base_users | self.user_id
374+
371375
def _message_failed_job(self):
372376
"""Return a message which will be posted on the job when it is failed.
373377

0 commit comments

Comments
 (0)