diff --git a/web_notify_upgrade/README.rst b/web_notify_upgrade/README.rst new file mode 100644 index 000000000000..1c508b3ed8da --- /dev/null +++ b/web_notify_upgrade/README.rst @@ -0,0 +1,90 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +================== +Web Notify Upgrade +================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:c19c68174a60ed18be65dbd1dd4464927509139187f14f42a4c378d48d73312b + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/19.0/web_notify_upgrade + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-19-0/web-19-0-web_notify_upgrade + :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/web&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module uses web_notify send a notification to every active users +whenever a module has been installed or upgraded. + +The notification will ask the user to refresh the page to get the latest +changes. + +|image1| + +.. |image1| image:: https://raw.githubusercontent.com/OCA/web/19.0/web_notify_upgrade/static/description/notify.png + +**Table of contents** + +.. contents:: + :local: + +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 +------- + +* Akretion + +Contributors +------------ + +- `Akretion `__: + + - Florian Mounier + +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/web `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_notify_upgrade/__init__.py b/web_notify_upgrade/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/web_notify_upgrade/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/web_notify_upgrade/__manifest__.py b/web_notify_upgrade/__manifest__.py new file mode 100644 index 000000000000..2d393a049f33 --- /dev/null +++ b/web_notify_upgrade/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2024 Akretion (http://www.akretion.com). +# @author Florian Mounier +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Web Notify Upgrade", + "summary": "Notify active users when a module is installed or updated", + "version": "19.0.1.0.0", + "license": "AGPL-3", + "depends": ["web_notify"], + "author": "Akretion, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/web", + "installable": True, +} diff --git a/web_notify_upgrade/i18n/fr.po b/web_notify_upgrade/i18n/fr.po new file mode 100644 index 000000000000..b262d01acac9 --- /dev/null +++ b/web_notify_upgrade/i18n/fr.po @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_notify_upgrade +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: 2024-08-14 16:58+0000\n" +"Last-Translator: David Beal \n" +"Language-Team: \n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 5.6.2\n" + +#. module: web_notify_upgrade +#: model:ir.model,name:web_notify_upgrade.model_ir_model_data +msgid "Model Data" +msgstr "Model Data" + +#. module: web_notify_upgrade +#. odoo-python +#: code:addons/web_notify_upgrade/models/ir_model.py:0 +#, python-format +msgid "Reload" +msgstr "Recharger" + +#. module: web_notify_upgrade +#. odoo-python +#: code:addons/web_notify_upgrade/models/ir_model.py:0 +#, python-format +msgid "Upgrade Notification" +msgstr "Notification de mise à jour" + +#. module: web_notify_upgrade +#. odoo-python +#: code:addons/web_notify_upgrade/models/ir_model.py:0 +#, python-format +msgid "Your odoo instance has been upgraded, please reload the web page." +msgstr "Votre instance odoo a été mise à jour, merci de recharger la page web." diff --git a/web_notify_upgrade/i18n/it.po b/web_notify_upgrade/i18n/it.po new file mode 100644 index 000000000000..9eca29655e4a --- /dev/null +++ b/web_notify_upgrade/i18n/it.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_notify_upgrade +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-08-12 08:58+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.6.2\n" + +#. module: web_notify_upgrade +#: model:ir.model,name:web_notify_upgrade.model_ir_model_data +msgid "Model Data" +msgstr "Dati modello" + +#. module: web_notify_upgrade +#. odoo-python +#: code:addons/web_notify_upgrade/models/ir_model.py:0 +#, python-format +msgid "Reload" +msgstr "Ricarica" + +#. module: web_notify_upgrade +#. odoo-python +#: code:addons/web_notify_upgrade/models/ir_model.py:0 +#, python-format +msgid "Upgrade Notification" +msgstr "Aggiorna notifiche" + +#. module: web_notify_upgrade +#. odoo-python +#: code:addons/web_notify_upgrade/models/ir_model.py:0 +#, python-format +msgid "Your odoo instance has been upgraded, please reload the web page." +msgstr "L'istanza Odoo è stata aggiornata, ricaricare la pagina web." diff --git a/web_notify_upgrade/i18n/sl.po b/web_notify_upgrade/i18n/sl.po new file mode 100644 index 000000000000..f2db0f7dc01e --- /dev/null +++ b/web_notify_upgrade/i18n/sl.po @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_notify_upgrade +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2026-06-06 12:01+0000\n" +"Last-Translator: Matjaz Mozetic \n" +"Language-Team: none\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || " +"n%100==4 ? 2 : 3;\n" +"X-Generator: Weblate 5.15.2\n" + +#. module: web_notify_upgrade +#: model:ir.model,name:web_notify_upgrade.model_ir_model_data +msgid "Model Data" +msgstr "Podatki modela" + +#. module: web_notify_upgrade +#. odoo-python +#: code:addons/web_notify_upgrade/models/ir_model.py:0 +msgid "Reload" +msgstr "Ponovno naloži" + +#. module: web_notify_upgrade +#. odoo-python +#: code:addons/web_notify_upgrade/models/ir_model.py:0 +msgid "Upgrade Notification" +msgstr "Obvestilo o nadgradnji" + +#. module: web_notify_upgrade +#. odoo-python +#: code:addons/web_notify_upgrade/models/ir_model.py:0 +msgid "Your odoo instance has been upgraded, please reload the web page." +msgstr "" +"Vaša instanca Odoo je bila posodobljena, prosimo, osvežite spletno stran." diff --git a/web_notify_upgrade/i18n/web_notify_upgrade.pot b/web_notify_upgrade/i18n/web_notify_upgrade.pot new file mode 100644 index 000000000000..68c79cfebbe9 --- /dev/null +++ b/web_notify_upgrade/i18n/web_notify_upgrade.pot @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_notify_upgrade +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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: web_notify_upgrade +#: model:ir.model,name:web_notify_upgrade.model_ir_model_data +msgid "Model Data" +msgstr "" + +#. module: web_notify_upgrade +#. odoo-python +#: code:addons/web_notify_upgrade/models/ir_model.py:0 +msgid "Reload" +msgstr "" + +#. module: web_notify_upgrade +#. odoo-python +#: code:addons/web_notify_upgrade/models/ir_model.py:0 +msgid "Upgrade Notification" +msgstr "" + +#. module: web_notify_upgrade +#. odoo-python +#: code:addons/web_notify_upgrade/models/ir_model.py:0 +msgid "Your odoo instance has been upgraded, please reload the web page." +msgstr "" diff --git a/web_notify_upgrade/models/__init__.py b/web_notify_upgrade/models/__init__.py new file mode 100644 index 000000000000..413bb2380140 --- /dev/null +++ b/web_notify_upgrade/models/__init__.py @@ -0,0 +1 @@ +from . import ir_model diff --git a/web_notify_upgrade/models/ir_model.py b/web_notify_upgrade/models/ir_model.py new file mode 100644 index 000000000000..f975223a377a --- /dev/null +++ b/web_notify_upgrade/models/ir_model.py @@ -0,0 +1,70 @@ +# Copyright 2024 Akretion (http://www.akretion.com). +# @author Florian Mounier +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import logging + +from odoo import api, models + +from odoo.addons.mail.models.mail_presence import AWAY_TIMER, DISCONNECTION_TIMER + +_logger = logging.getLogger(__name__) + + +class IrModelData(models.Model): + _inherit = "ir.model.data" + + @api.model + def _process_end(self, modules): + # This function is called at the end of the module installation + # only if at least a module has been installed or updated. + rv = super()._process_end(modules) + self._notify_active_users_of_upgrade() + return rv + + def _notify_active_users_of_upgrade(self): + # Look for active users + active_users = self._get_active_users_to_notify_of_upgrade() + if active_users: + _logger.info( + "Installation detected. Notifying %s active users", len(active_users) + ) + # Notify them + active_users.notify_info(**self._get_upgrade_notification_params()) + + def _get_active_users_to_notify_of_upgrade(self): + """Return the active users that should be notified of the upgrade.""" + self.env.cr.execute( + """ + SELECT user_id + FROM mail_presence + WHERE last_poll is not null + AND ( + age(now() AT TIME ZONE 'UTC', last_poll) < interval %s + OR age(now() AT TIME ZONE 'UTC', last_presence) < interval %s + ) + """, + (f"{DISCONNECTION_TIMER} seconds", f"{AWAY_TIMER} seconds"), + ) + return self.env["res.users"].browse([res[0] for res in self.env.cr.fetchall()]) + + def _get_upgrade_notification_params(self): + """Return the parameters to pass to the notify_info method.""" + action = { + "type": "ir.actions.client", + "tag": "reload", + "context": { + "params": { + "button_name": self.env._("Reload"), + "button_icon": "fa-refresh", + } + }, + } + + return { + "message": self.env._( + "Your odoo instance has been upgraded, please reload the web page." + ), + "action": action, + "title": self.env._("Upgrade Notification"), + "sticky": True, + } diff --git a/web_notify_upgrade/pyproject.toml b/web_notify_upgrade/pyproject.toml new file mode 100644 index 000000000000..4231d0cccb3d --- /dev/null +++ b/web_notify_upgrade/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/web_notify_upgrade/readme/CONTRIBUTORS.md b/web_notify_upgrade/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..3b52e04e621e --- /dev/null +++ b/web_notify_upgrade/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Akretion](https://www.akretion.com): + - Florian Mounier diff --git a/web_notify_upgrade/readme/DESCRIPTION.md b/web_notify_upgrade/readme/DESCRIPTION.md new file mode 100644 index 000000000000..1e3a0476e3e7 --- /dev/null +++ b/web_notify_upgrade/readme/DESCRIPTION.md @@ -0,0 +1,7 @@ +This module uses web_notify send a notification to every active users +whenever a module has been installed or upgraded. + +The notification will ask the user to refresh the page to get the latest +changes. + +![](../static/description/notify.png) diff --git a/web_notify_upgrade/static/description/icon.png b/web_notify_upgrade/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/web_notify_upgrade/static/description/icon.png differ diff --git a/web_notify_upgrade/static/description/index.html b/web_notify_upgrade/static/description/index.html new file mode 100644 index 000000000000..e96502f770cc --- /dev/null +++ b/web_notify_upgrade/static/description/index.html @@ -0,0 +1,436 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Web Notify Upgrade

+ +

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

+

This module uses web_notify send a notification to every active users +whenever a module has been installed or upgraded.

+

The notification will ask the user to refresh the page to get the latest +changes.

+

image1

+

Table of contents

+ +
+

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

+
    +
  • Akretion
  • +
+
+
+

Contributors

+ +
+
+

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/web project on GitHub.

+

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

+
+
+
+
+ + diff --git a/web_notify_upgrade/static/description/notify.png b/web_notify_upgrade/static/description/notify.png new file mode 100644 index 000000000000..d605e3ff894e Binary files /dev/null and b/web_notify_upgrade/static/description/notify.png differ