diff --git a/setup/web_notify_upgrade/odoo/addons/web_notify_upgrade b/setup/web_notify_upgrade/odoo/addons/web_notify_upgrade new file mode 120000 index 000000000..276bb5108 --- /dev/null +++ b/setup/web_notify_upgrade/odoo/addons/web_notify_upgrade @@ -0,0 +1 @@ +../../../../web_notify_upgrade \ No newline at end of file diff --git a/setup/web_notify_upgrade/setup.py b/setup/web_notify_upgrade/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/web_notify_upgrade/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_notify_upgrade/README.rst b/web_notify_upgrade/README.rst new file mode 100644 index 000000000..ac632893c --- /dev/null +++ b/web_notify_upgrade/README.rst @@ -0,0 +1,84 @@ +================== +Web Notify Upgrade +================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:73f36f681a3bdab0c199d3f256b69f03aba5a56d03e9a35545d14d1992c865bd + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/16.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-16-0/web-16-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=16.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. + + +.. figure:: https://raw.githubusercontent.com/OCA/web/16.0/web_notify_upgrade/static/description/notify.png + :alt: Refresh page + +**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 000000000..0650744f6 --- /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 000000000..24ae27e06 --- /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": "16.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 000000000..f7cc2012b --- /dev/null +++ b/web_notify_upgrade/i18n/fr.po @@ -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 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: \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: Poedit 3.0.1\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 "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/web_notify_upgrade.pot b/web_notify_upgrade/i18n/web_notify_upgrade.pot new file mode 100644 index 000000000..eafc4e86c --- /dev/null +++ b/web_notify_upgrade/i18n/web_notify_upgrade.pot @@ -0,0 +1,40 @@ +# 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" +"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 "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/models/__init__.py b/web_notify_upgrade/models/__init__.py new file mode 100644 index 000000000..413bb2380 --- /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 000000000..d973e4e36 --- /dev/null +++ b/web_notify_upgrade/models/ir_model.py @@ -0,0 +1,61 @@ +# 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.bus.models.bus_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 bus_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 + ) + """, + ("%s seconds" % DISCONNECTION_TIMER, "%s seconds" % AWAY_TIMER), + ) + 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.""" + return dict( + message=_( + "Your odoo instance has been upgraded, " "please reload the web page." + ) + + "
" + '", + title=_("Upgrade Notification"), + sticky=True, + ) diff --git a/web_notify_upgrade/readme/CONTRIBUTORS.rst b/web_notify_upgrade/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..a4d0ad922 --- /dev/null +++ b/web_notify_upgrade/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Akretion `_: + + * Florian Mounier diff --git a/web_notify_upgrade/readme/DESCRIPTION.rst b/web_notify_upgrade/readme/DESCRIPTION.rst new file mode 100644 index 000000000..49656f4d6 --- /dev/null +++ b/web_notify_upgrade/readme/DESCRIPTION.rst @@ -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. + + +.. figure:: ../static/description/notify.png + :alt: Refresh page diff --git a/web_notify_upgrade/static/description/index.html b/web_notify_upgrade/static/description/index.html new file mode 100644 index 000000000..61d39b54d --- /dev/null +++ b/web_notify_upgrade/static/description/index.html @@ -0,0 +1,427 @@ + + + + + +Web Notify Upgrade + + + +
+

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.

+
+Refresh page +
+

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 000000000..d605e3ff8 Binary files /dev/null and b/web_notify_upgrade/static/description/notify.png differ