diff --git a/queue_job_web_notify/README.rst b/queue_job_web_notify/README.rst new file mode 100644 index 0000000000..e384ee85a1 --- /dev/null +++ b/queue_job_web_notify/README.rst @@ -0,0 +1,108 @@ +==================== +Queue Job Web Notify +==================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:5323f093bbd847963317ba481fa1b5e7cf038371945dd75145ebc6d72af59e41 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fqueue-lightgray.png?logo=github + :target: https://github.com/OCA/queue/tree/14.0/queue_job_web_notify + :alt: OCA/queue +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/queue-14-0/queue-14-0-queue_job_web_notify + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/queue&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the mail notification feature of Queue Job. It adds +the possibility to enable the web notification of failed jobs. When +enabled, the user will be notified by a web notification. The web +notification is a pop-up message that appears in the user's browser. + +**Table of contents** + +.. contents:: + :local: + +Use Cases / Context +=================== + +The notification feature of this module allows the user to get a +immediate feedback about the status of the job. + +Configuration +============= + +To configure this module, you need to: + +- Go to the list of queue job functions +- Enable the web notify feature + +Usage +===== + +To only usage of this module is its configuration: + +- Go to the list of queue job functions +- Enable the web notify feature + +Known issues / Roadmap +====================== + +- other notification contexts could be added (job started, job + finished, job canceled, etc.) + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* ACSONE SA/NV + +Contributors +------------ + +- Thomas Binsfeld thomas.binsfeld@acsone.eu (https://www.acsone.eu/) +- Maxime Franco maxime.franco@acsone.eu (https://www.acsone.eu/) + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/queue `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/queue_job_web_notify/__init__.py b/queue_job_web_notify/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/queue_job_web_notify/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/queue_job_web_notify/__manifest__.py b/queue_job_web_notify/__manifest__.py new file mode 100644 index 0000000000..2195ec5950 --- /dev/null +++ b/queue_job_web_notify/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2024 ACSONE SA/NV,Odoo Community Association (OCA) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Queue Job Web Notify", + "summary": """ + This module allows to display a notification to the related user of a + failed job. It uses the web_notify notification feature.""", + "version": "14.0.1.0.0", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/queue", + "license": "AGPL-3", + "category": "Generic Modules", + "depends": [ + # OCA/queue + "queue_job", + # OCA/web + "web_notify", + ], + "data": ["views/queue_job_function.xml"], +} diff --git a/queue_job_web_notify/i18n/fr.po b/queue_job_web_notify/i18n/fr.po new file mode 100644 index 0000000000..13de6298c5 --- /dev/null +++ b/queue_job_web_notify/i18n/fr.po @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * queue_job_web_notify +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-03-04 13:47+0000\n" +"PO-Revision-Date: 2024-03-04 13:47+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: queue_job_web_notify +#: model:ir.model.fields,help:queue_job_web_notify.field_queue_job_function__is_web_notify_failure_enabled +msgid "Display a notification in the user interface when the job fails." +msgstr "Affiche une notification dans l'interface utilisateur lorsque le job échoue." + +#. module: queue_job_web_notify +#: model:ir.model,name:queue_job_web_notify.model_queue_job_function +msgid "Job Functions" +msgstr "" + +#. module: queue_job_web_notify +#: code:addons/queue_job_web_notify/models/queue_job.py:0 +#, python-format +msgid "Job failed" +msgstr "Job échoué" + +#. module: queue_job_web_notify +#: model:ir.model.fields,field_description:queue_job_web_notify.field_queue_job_function__is_web_notify_failure_enabled +msgid "Notify on failure" +msgstr "Notifier en cas d'échec" + +#. module: queue_job_web_notify +#: model:ir.model,name:queue_job_web_notify.model_queue_job +msgid "Queue Job" +msgstr "" diff --git a/queue_job_web_notify/i18n/queue_job_web_notify.pot b/queue_job_web_notify/i18n/queue_job_web_notify.pot new file mode 100644 index 0000000000..5bc8e5e059 --- /dev/null +++ b/queue_job_web_notify/i18n/queue_job_web_notify.pot @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * queue_job_web_notify +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: queue_job_web_notify +#: model:ir.model.fields,help:queue_job_web_notify.field_queue_job_function__is_web_notify_failure_enabled +msgid "Display a notification in the user interface when the job fails." +msgstr "" + +#. module: queue_job_web_notify +#: model:ir.model,name:queue_job_web_notify.model_queue_job_function +msgid "Job Functions" +msgstr "" + +#. module: queue_job_web_notify +#: code:addons/queue_job_web_notify/models/queue_job.py:0 +#, python-format +msgid "Job failed" +msgstr "" + +#. module: queue_job_web_notify +#: model:ir.model.fields,field_description:queue_job_web_notify.field_queue_job_function__is_web_notify_failure_enabled +msgid "Notify on failure" +msgstr "" + +#. module: queue_job_web_notify +#: model:ir.model,name:queue_job_web_notify.model_queue_job +msgid "Queue Job" +msgstr "" diff --git a/queue_job_web_notify/models/__init__.py b/queue_job_web_notify/models/__init__.py new file mode 100644 index 0000000000..2cf4503488 --- /dev/null +++ b/queue_job_web_notify/models/__init__.py @@ -0,0 +1,2 @@ +from . import queue_job_function +from . import queue_job diff --git a/queue_job_web_notify/models/queue_job.py b/queue_job_web_notify/models/queue_job.py new file mode 100644 index 0000000000..0f2d5e8a81 --- /dev/null +++ b/queue_job_web_notify/models/queue_job.py @@ -0,0 +1,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 diff --git a/queue_job_web_notify/models/queue_job_function.py b/queue_job_web_notify/models/queue_job_function.py new file mode 100644 index 0000000000..5633d1e46c --- /dev/null +++ b/queue_job_web_notify/models/queue_job_function.py @@ -0,0 +1,14 @@ +# Copyright 2024 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class QueueJobFunction(models.Model): + _inherit = "queue.job.function" + + is_web_notify_failure_enabled = fields.Boolean( + string="Notify on failure", + help="Display a notification in the user interface when the job fails.", + default=False, + ) diff --git a/queue_job_web_notify/readme/CONFIGURE.md b/queue_job_web_notify/readme/CONFIGURE.md new file mode 100644 index 0000000000..9c322159df --- /dev/null +++ b/queue_job_web_notify/readme/CONFIGURE.md @@ -0,0 +1,4 @@ +To configure this module, you need to: + +- Go to the list of queue job functions +- Enable the web notify feature diff --git a/queue_job_web_notify/readme/CONTEXT.md b/queue_job_web_notify/readme/CONTEXT.md new file mode 100644 index 0000000000..75f4b9e2d6 --- /dev/null +++ b/queue_job_web_notify/readme/CONTEXT.md @@ -0,0 +1,2 @@ +The notification feature of this module allows the user to get a immediate feedback +about the status of the job. diff --git a/queue_job_web_notify/readme/CONTRIBUTORS.md b/queue_job_web_notify/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..35e59105e3 --- /dev/null +++ b/queue_job_web_notify/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Thomas Binsfeld (https://www.acsone.eu/) +- Maxime Franco (https://www.acsone.eu/) diff --git a/queue_job_web_notify/readme/DESCRIPTION.md b/queue_job_web_notify/readme/DESCRIPTION.md new file mode 100644 index 0000000000..8f1dbc70c0 --- /dev/null +++ b/queue_job_web_notify/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +This module extends the mail notification feature of Queue Job. It adds the possibility +to enable the web notification of failed jobs. When enabled, the user will be notified +by a web notification. The web notification is a pop-up message that appears in the +user's browser. diff --git a/queue_job_web_notify/readme/ROADMAP.md b/queue_job_web_notify/readme/ROADMAP.md new file mode 100644 index 0000000000..86a295f402 --- /dev/null +++ b/queue_job_web_notify/readme/ROADMAP.md @@ -0,0 +1,2 @@ +- other notification contexts could be added (job started, job finished, job canceled, + etc.) diff --git a/queue_job_web_notify/readme/USAGE.md b/queue_job_web_notify/readme/USAGE.md new file mode 100644 index 0000000000..969cf2e8ec --- /dev/null +++ b/queue_job_web_notify/readme/USAGE.md @@ -0,0 +1,4 @@ +To only usage of this module is its configuration: + +- Go to the list of queue job functions +- Enable the web notify feature diff --git a/queue_job_web_notify/static/description/icon.png b/queue_job_web_notify/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/queue_job_web_notify/static/description/icon.png differ diff --git a/queue_job_web_notify/static/description/index.html b/queue_job_web_notify/static/description/index.html new file mode 100644 index 0000000000..4e716e3169 --- /dev/null +++ b/queue_job_web_notify/static/description/index.html @@ -0,0 +1,459 @@ + + + + + +Queue Job Web Notify + + + +
+

Queue Job Web Notify

+ + +

Beta License: AGPL-3 OCA/queue Translate me on Weblate Try me on Runboat

+

This module extends the mail notification feature of Queue Job. It adds +the possibility to enable the web notification of failed jobs. When +enabled, the user will be notified by a web notification. The web +notification is a pop-up message that appears in the user’s browser.

+

Table of contents

+ +
+

Use Cases / Context

+

The notification feature of this module allows the user to get a +immediate feedback about the status of the job.

+
+
+

Configuration

+

To configure this module, you need to:

+
    +
  • Go to the list of queue job functions
  • +
  • Enable the web notify feature
  • +
+
+
+

Usage

+

To only usage of this module is its configuration:

+
    +
  • Go to the list of queue job functions
  • +
  • Enable the web notify feature
  • +
+
+
+

Known issues / Roadmap

+
    +
  • other notification contexts could be added (job started, job +finished, job canceled, etc.)
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/queue project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/queue_job_web_notify/views/queue_job_function.xml b/queue_job_web_notify/views/queue_job_function.xml new file mode 100644 index 0000000000..7940f58603 --- /dev/null +++ b/queue_job_web_notify/views/queue_job_function.xml @@ -0,0 +1,16 @@ + + + + + queue.job.function + + + + + + + + + + diff --git a/setup/queue_job_web_notify/odoo/addons/queue_job_web_notify b/setup/queue_job_web_notify/odoo/addons/queue_job_web_notify new file mode 120000 index 0000000000..eecc30dc05 --- /dev/null +++ b/setup/queue_job_web_notify/odoo/addons/queue_job_web_notify @@ -0,0 +1 @@ +../../../../queue_job_web_notify \ No newline at end of file diff --git a/setup/queue_job_web_notify/setup.py b/setup/queue_job_web_notify/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/queue_job_web_notify/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)