-
-
Notifications
You must be signed in to change notification settings - Fork 560
Expand file tree
/
Copy pathqueue_job.py
More file actions
28 lines (22 loc) · 900 Bytes
/
queue_job.py
File metadata and controls
28 lines (22 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import _, models
class QueueJob(models.Model):
_inherit = "queue.job"
def _get_web_notify_failure_title(self):
self.ensure_one()
return _("Job failed")
def _get_web_notify_failure_message(self):
self.ensure_one()
return self.display_name
def _message_post_on_failure(self):
res = super()._message_post_on_failure()
for job in self:
if not job.job_function_id.is_web_notify_failure_enabled:
continue
notification_title = job._get_web_notify_failure_title()
notification_message = job._get_web_notify_failure_message()
job.user_id.notify_danger(
message=notification_message, title=notification_title, sticky=True
)
return res