diff --git a/mail_push_notification/README.rst b/mail_push_notification/README.rst new file mode 100644 index 000000000..85da5b4a8 --- /dev/null +++ b/mail_push_notification/README.rst @@ -0,0 +1,48 @@ +.. image:: https://img.shields.io/badge/license-LGPL--3-green.svg + :target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 + +Push Notification From ChatBox +============================== +* Push Notification From ChatBox is valuable for teams looking to streamline communication and enhance productivity within the Odoo platform. + +Configuration +============= +* Install the pyfcm python package +* Install our module and make sure that your instance served over https.Firebase is intent on being a highly secure solution, so they have chosen to require the use of a https for all communication and http is not working. +* After installation of module its important that allow the notification access in the webpage + +Company +------- +* `Cybrosys Techno Solutions `__ + +License +------- +Lesser General Public License, Version 3 (LGPL v3). +(https://www.gnu.org/licenses/lgpl-3.0-standalone.html) + +Credits +------- +Developer: (V16) Gokul P I , Contact: odoo@cybrosys.com + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Maintainer +========== +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit `Our Website `__ + +Further information +=================== +HTML Description: ``__ diff --git a/mail_push_notification/__init__.py b/mail_push_notification/__init__.py new file mode 100755 index 000000000..9e5f5ab1d --- /dev/null +++ b/mail_push_notification/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import controllers +from . import models diff --git a/mail_push_notification/__manifest__.py b/mail_push_notification/__manifest__.py new file mode 100755 index 000000000..4dd8b8163 --- /dev/null +++ b/mail_push_notification/__manifest__.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +{ + "name": "Push Notification From ChatBox", + 'version': '16.0.1.0.0', + 'category': 'Discuss,Extra Tools', + 'summary': 'With Push Notification From ChatBox, users can respond promptly' + ' to important messages, improving communication efficiency.', + 'description': 'Push Notification From ChatBox is valuable for teams ' + 'looking to streamline communication and enhance ' + 'productivity within the Odoo platform.', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + "depends": ["web", "mail"], + "data": [ + "security/ir.model.access.csv", + "views/res_config_settings_views.xml" + ], + 'assets': { + 'web.assets_backend': [ + "https://www.gstatic.com/firebasejs/8.4.3/firebase-app.js", + "https://www.gstatic.com/firebasejs/8.4.3/firebase-messaging.js", + "mail_push_notification/static/src/js/firebase.js", + ], + }, + "external_dependencies": {"python": ["pyfcm"]}, + 'images': ['static/description/banner.png'], + 'license': 'LGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/mail_push_notification/controllers/__init__.py b/mail_push_notification/controllers/__init__.py new file mode 100755 index 000000000..7c5feb144 --- /dev/null +++ b/mail_push_notification/controllers/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import mail_push_notification diff --git a/mail_push_notification/controllers/mail_push_notification.py b/mail_push_notification/controllers/mail_push_notification.py new file mode 100755 index 000000000..3a290380b --- /dev/null +++ b/mail_push_notification/controllers/mail_push_notification.py @@ -0,0 +1,122 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +import json +from odoo import http +from odoo.http import request + + +class MailPushNotification(http.Controller): + """Controller for handling push notifications using Firebase + Cloud Messaging""" + + @http.route('/firebase-messaging-sw.js', type='http', auth="public") + def firebase_http(self): + """Returns the Firebase service worker script. + :return: The Firebase service worker script. + :rtype: str""" + if request.env.company and request.env.company.push_notification: + firebase_js = """ + this.addEventListener('fetch', function(e) { + e.respondWith( + caches.match(e.request).then(function(response) { + return response || fetch(e.request); + }) + ); + }); + importScripts('https://www.gstatic.com/firebasejs/8.4.2/firebase-app.js'); + importScripts('https://www.gstatic.com/firebasejs/8.4.2/firebase-messaging.js'); + var firebaseConfig = { + apiKey: '%s', + authDomain: '%s', + projectId: '%s', + storageBucket: '%s', + messagingSenderId: '%s', + appId: '%s', + measurementId: '%s', + }; + firebase.initializeApp(firebaseConfig); + const messaging = firebase.messaging(); + messaging.setBackgroundMessageHandler(function(payload) { + const notificationTitle = "Background Message Title"; + const notificationOptions = { + body: payload.notification.body, + icon:'/mail_push_notification/static/description/icon.png', + }; + return self.registration.showNotification( + notificationTitle, + notificationOptions, + ); + }); + """ % ( + request.env.company.api_key, request.env.company.auth_domain, + request.env.company.project_id_firebase, + request.env.company.storage_bucket, + request.env.company.messaging_sender_id_firebase, + request.env.company.app_id_firebase, + request.env.company.measurement_id_firebase) + else: + firebase_js = """ + this.addEventListener('fetch', function(e) { + e.respondWith( + caches.match(e.request).then(function(response) { + return response || fetch(e.request); + }) + ); + }); + """ + return http.request.make_response(firebase_js, [ + ('Content-Type', 'text/javascript')]) + + @http.route('/push_notification', type='http', auth="public", + csrf=False) + def get_registration_tokens(self, **post): + """Handles registration tokens for push notifications. + Create a new registration token if it doesn't already exist + :param post: POST request data containing registration token. + :type post: dict + """ + user_notification = request.env['push.notification'].sudo().search( + [('register_id', '=', post.get('name'))], limit=1) + if not user_notification: + request.env['push.notification'].sudo().create({ + 'register_id': post.get('name'), + 'user_id': request.env.user.id + }) + + @http.route('/firebase_config_details', type='json', auth="public") + def send_datas(self): + """Sends Firebase configuration details. + :return: JSON containing Firebase configuration details. + :rtype: str""" + if request.env.company and request.env.company.push_notification: + return json.dumps({ + 'vapid': request.env.company.vapid, + 'config': { + 'apiKey': request.env.company.api_key, + 'authDomain': request.env.company.auth_domain, + 'projectId': request.env.company.project_id_firebase, + 'storageBucket': request.env.company.storage_bucket, + 'messagingSenderId': request.env.company.messaging_sender_id_firebase, + 'appId': request.env.company.app_id_firebase, + 'measurementId': request.env.company.measurement_id_firebase + } + }) diff --git a/mail_push_notification/doc/RELEASE_NOTES.md b/mail_push_notification/doc/RELEASE_NOTES.md new file mode 100755 index 000000000..9e263fd07 --- /dev/null +++ b/mail_push_notification/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 25.10.2023 +#### Version 16.0.1.0.0 +#### ADD +- Initial commit for Push Notification From ChatBox diff --git a/mail_push_notification/models/__init__.py b/mail_push_notification/models/__init__.py new file mode 100755 index 000000000..47a182814 --- /dev/null +++ b/mail_push_notification/models/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import mail_thread +from . import push_notification +from . import res_company +from . import res_config_settings diff --git a/mail_push_notification/models/mail_thread.py b/mail_push_notification/models/mail_thread.py new file mode 100644 index 000000000..8c51dcb5d --- /dev/null +++ b/mail_push_notification/models/mail_thread.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from pyfcm import FCMNotification +from odoo import models + + +class MailThread(models.AbstractModel): + """Inherits MailThread to send notifications using chatterbox""" + _inherit = 'mail.thread' + + def _notify_thread(self, message, msg_vals=False, **kwargs): + """Supering the _notify_thread() function to fetch the details of the + chat message and push that message as a notification """ + res = super(MailThread, self)._notify_thread(message, + msg_vals=msg_vals, + **kwargs) + msg = message.read() + if self.env.company.push_notification and self.env.user.has_group( + 'base.group_user'): + try: + push_service = FCMNotification( + api_key=self.env.company.server_key) + receiver_id = False + domain = [] + if self.channel_type != 'channel': + for partner in self.channel_partner_ids: + if partner.id != msg[0]['author_id'][0]: + receiver_id = self.env['res.users'].search([( + 'partner_id', + '=', + partner.id)]) + if receiver_id: + domain = [('user_id', '=', + receiver_id.id)] + push_service.notify_multiple_devices( + registration_ids=[registration_id.register_id for + registration_id in + self.env['push.notification'].search( + domain)], + message_title='Send by ' + msg[0]['author_id'][1], + message_body=msg[0]['description'], + extra_notification_kwargs={ + 'click_action': '/web' + }) + except Exception: + pass + return res diff --git a/mail_push_notification/models/push_notification.py b/mail_push_notification/models/push_notification.py new file mode 100755 index 000000000..6c451b579 --- /dev/null +++ b/mail_push_notification/models/push_notification.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import fields, models + + +class PushNotification(models.Model): + """Using this class create the registration id for the user to send + push notifications""" + _name = 'push.notification' + _description = 'Web Push Notification' + + user_id = fields.Many2one("res.users", string="Firebase User", + help="Corresponding Firebase User") + register_id = fields.Char(string="Registration Id", + help="Firebase Registration Token") diff --git a/mail_push_notification/models/res_company.py b/mail_push_notification/models/res_company.py new file mode 100644 index 000000000..6d355aa79 --- /dev/null +++ b/mail_push_notification/models/res_company.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import fields, models + + +class ResCompany(models.Model): + """Inheriting this class to add the firebase credential need in config + settings and use the multi company feature""" + _inherit = 'res.company' + + push_notification = fields.Boolean(string='Enable Push Notification', + help="Enable Web Push Notification") + server_key = fields.Char(string="Server Key", + help="Server Key of the firebase") + vapid = fields.Char(string="Vapid", help='VapId of the firebase', + readonly=False) + api_key = fields.Char(string="Api Key", + help='Corresponding apiKey of firebase config', + readonly=False) + auth_domain = fields.Char(string="Auth Domain", + help='Corresponding authDomain of firebase ' + 'config') + project_id_firebase = fields.Char(string="Project Id", + help='Corresponding projectId of ' + 'firebase config') + storage_bucket = fields.Char(string="Storage Bucket", + help='Corresponding storageBucket of ' + 'firebase config') + messaging_sender_id_firebase = fields.Char(string="Messaging Sender Id", + help='Corresponding ' + 'messagingSenderId of ' + 'firebase config') + app_id_firebase = fields.Char(string="App Id", + help='Corresponding appId of firebase config') + measurement_id_firebase = fields.Char(string="Measurement Id", + help='Corresponding measurementId ' + 'of firebase config') diff --git a/mail_push_notification/models/res_config_settings.py b/mail_push_notification/models/res_config_settings.py new file mode 100644 index 000000000..ec85c9fef --- /dev/null +++ b/mail_push_notification/models/res_config_settings.py @@ -0,0 +1,116 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Gokul PI () +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from pyfcm import FCMNotification +from odoo import fields, models, _ + + +class ResConfigSettings(models.TransientModel): + """Inheriting the ResConfigSettings to add the firebase config details + to push notifications """ + _inherit = 'res.config.settings' + + push_notification = fields.Boolean(string='Enable Push Notification', + help="Enable Web Push Notification", + related='company_id.push_notification', + readonly=False) + server_key = fields.Char(string="Server Key", + help="Server Key of the firebase", + related='company_id.server_key', readonly=False) + vapid = fields.Char(string="Vapid", help='VapId of the firebase', + related='company_id.vapid', readonly=False) + api_key = fields.Char(string="Api Key", + help='Corresponding apiKey of firebase config', + related='company_id.api_key', readonly=False) + auth_domain = fields.Char(string="Auth Domain", + help='Corresponding authDomain of firebase ' + 'config', + related='company_id.auth_domain', readonly=False) + project_id_firebase = fields.Char(string="Project Id", + help='Corresponding projectId of ' + 'firebase config', + related='company_id.project_id_firebase', + readonly=False) + storage_bucket = fields.Char(string="Storage Bucket", + help='Corresponding storageBucket of ' + 'firebase config', + related='company_id.storage_bucket', + readonly=False) + messaging_sender_id_firebase = fields.Char(string="Messaging Sender Id", + help='Corresponding ' + 'messagingSenderId of ' + 'firebase config', + related='company_id' + '.messaging_sender_id_firebase', + readonly=False) + app_id_firebase = fields.Char(string="App Id", + help='Corresponding appId of firebase config', + related='company_id.app_id_firebase', + readonly=False) + measurement_id_firebase = fields.Char(string="Measurement Id", + help='Corresponding measurementId ' + 'of firebase config', + related='company_id' + '.measurement_id_firebase', + readonly=False) + + def test_connection(self): + """Test connection to firebase using the firebase credentials""" + if self.env.company.push_notification: + try: + push_service = FCMNotification( + api_key=self.env.company.server_key) + registration_ids = self.env['push.notification'].sudo().search( + [('user_id', '=', self.env.user.id)]) + push_service.notify_multiple_devices( + registration_ids=[registration_id.register_id for + registration_id in registration_ids], + message_title='Test Connection', + message_body='Successfully', + extra_notification_kwargs={ + 'click_action': '/web' + }) + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'type': 'success', + 'message': _("Connection successfully established"), + 'next': { + 'type': 'ir.actions.client', + 'tag': 'reload_context', + }, + } + } + except: + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'type': 'danger', + 'message': _( + "Failed to connect with firebase"), + 'next': { + 'type': 'ir.actions.client', + 'tag': 'reload_context', + }, + } + } diff --git a/mail_push_notification/security/ir.model.access.csv b/mail_push_notification/security/ir.model.access.csv new file mode 100755 index 000000000..1ab429df2 --- /dev/null +++ b/mail_push_notification/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_push_notification_user,access.push.notification.user,model_push_notification,base.group_user,1,1,1,1 diff --git a/mail_push_notification/static/description/assets/icons/check.png b/mail_push_notification/static/description/assets/icons/check.png new file mode 100755 index 000000000..c8e85f51d Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/check.png differ diff --git a/mail_push_notification/static/description/assets/icons/chevron.png b/mail_push_notification/static/description/assets/icons/chevron.png new file mode 100755 index 000000000..2089293d6 Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/chevron.png differ diff --git a/mail_push_notification/static/description/assets/icons/cogs.png b/mail_push_notification/static/description/assets/icons/cogs.png new file mode 100755 index 000000000..95d0bad62 Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/cogs.png differ diff --git a/mail_push_notification/static/description/assets/icons/consultation.png b/mail_push_notification/static/description/assets/icons/consultation.png new file mode 100755 index 000000000..8319d4baa Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/consultation.png differ diff --git a/mail_push_notification/static/description/assets/icons/ecom-black.png b/mail_push_notification/static/description/assets/icons/ecom-black.png new file mode 100755 index 000000000..a9385ff13 Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/ecom-black.png differ diff --git a/mail_push_notification/static/description/assets/icons/education-black.png b/mail_push_notification/static/description/assets/icons/education-black.png new file mode 100755 index 000000000..3eb09b27b Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/education-black.png differ diff --git a/mail_push_notification/static/description/assets/icons/hotel-black.png b/mail_push_notification/static/description/assets/icons/hotel-black.png new file mode 100755 index 000000000..130f613be Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/hotel-black.png differ diff --git a/mail_push_notification/static/description/assets/icons/license.png b/mail_push_notification/static/description/assets/icons/license.png new file mode 100755 index 000000000..a5869797e Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/license.png differ diff --git a/mail_push_notification/static/description/assets/icons/lifebuoy.png b/mail_push_notification/static/description/assets/icons/lifebuoy.png new file mode 100755 index 000000000..658d56ccc Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/lifebuoy.png differ diff --git a/mail_push_notification/static/description/assets/icons/manufacturing-black.png b/mail_push_notification/static/description/assets/icons/manufacturing-black.png new file mode 100755 index 000000000..697eb0e9f Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/manufacturing-black.png differ diff --git a/mail_push_notification/static/description/assets/icons/pos-black.png b/mail_push_notification/static/description/assets/icons/pos-black.png new file mode 100755 index 000000000..97c0f90c1 Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/pos-black.png differ diff --git a/mail_push_notification/static/description/assets/icons/puzzle.png b/mail_push_notification/static/description/assets/icons/puzzle.png new file mode 100755 index 000000000..65cf854e7 Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/puzzle.png differ diff --git a/mail_push_notification/static/description/assets/icons/restaurant-black.png b/mail_push_notification/static/description/assets/icons/restaurant-black.png new file mode 100755 index 000000000..4a35eb939 Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/restaurant-black.png differ diff --git a/mail_push_notification/static/description/assets/icons/service-black.png b/mail_push_notification/static/description/assets/icons/service-black.png new file mode 100755 index 000000000..301ab51cb Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/service-black.png differ diff --git a/mail_push_notification/static/description/assets/icons/trading-black.png b/mail_push_notification/static/description/assets/icons/trading-black.png new file mode 100755 index 000000000..9398ba2f1 Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/trading-black.png differ diff --git a/mail_push_notification/static/description/assets/icons/training.png b/mail_push_notification/static/description/assets/icons/training.png new file mode 100755 index 000000000..884ca024d Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/training.png differ diff --git a/mail_push_notification/static/description/assets/icons/update.png b/mail_push_notification/static/description/assets/icons/update.png new file mode 100755 index 000000000..ecbc5a01a Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/update.png differ diff --git a/mail_push_notification/static/description/assets/icons/user.png b/mail_push_notification/static/description/assets/icons/user.png new file mode 100755 index 000000000..6ffb23d9f Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/user.png differ diff --git a/mail_push_notification/static/description/assets/icons/wrench.png b/mail_push_notification/static/description/assets/icons/wrench.png new file mode 100755 index 000000000..6c04dea0f Binary files /dev/null and b/mail_push_notification/static/description/assets/icons/wrench.png differ diff --git a/mail_push_notification/static/description/assets/misc/categories.png b/mail_push_notification/static/description/assets/misc/categories.png new file mode 100755 index 000000000..bedf1e0b1 Binary files /dev/null and b/mail_push_notification/static/description/assets/misc/categories.png differ diff --git a/mail_push_notification/static/description/assets/misc/check-box.png b/mail_push_notification/static/description/assets/misc/check-box.png new file mode 100755 index 000000000..42caf24b9 Binary files /dev/null and b/mail_push_notification/static/description/assets/misc/check-box.png differ diff --git a/mail_push_notification/static/description/assets/misc/compass.png b/mail_push_notification/static/description/assets/misc/compass.png new file mode 100755 index 000000000..d5fed8faa Binary files /dev/null and b/mail_push_notification/static/description/assets/misc/compass.png differ diff --git a/mail_push_notification/static/description/assets/misc/corporate.png b/mail_push_notification/static/description/assets/misc/corporate.png new file mode 100755 index 000000000..2eb13edbf Binary files /dev/null and b/mail_push_notification/static/description/assets/misc/corporate.png differ diff --git a/mail_push_notification/static/description/assets/misc/customer-support.png b/mail_push_notification/static/description/assets/misc/customer-support.png new file mode 100755 index 000000000..79efc72ed Binary files /dev/null and b/mail_push_notification/static/description/assets/misc/customer-support.png differ diff --git a/mail_push_notification/static/description/assets/misc/cybrosys-logo.png b/mail_push_notification/static/description/assets/misc/cybrosys-logo.png new file mode 100755 index 000000000..cc3cc0ccf Binary files /dev/null and b/mail_push_notification/static/description/assets/misc/cybrosys-logo.png differ diff --git a/mail_push_notification/static/description/assets/misc/features.png b/mail_push_notification/static/description/assets/misc/features.png new file mode 100755 index 000000000..b41769f77 Binary files /dev/null and b/mail_push_notification/static/description/assets/misc/features.png differ diff --git a/mail_push_notification/static/description/assets/misc/logo.png b/mail_push_notification/static/description/assets/misc/logo.png new file mode 100755 index 000000000..478462d3e Binary files /dev/null and b/mail_push_notification/static/description/assets/misc/logo.png differ diff --git a/mail_push_notification/static/description/assets/misc/pictures.png b/mail_push_notification/static/description/assets/misc/pictures.png new file mode 100755 index 000000000..56d255fe9 Binary files /dev/null and b/mail_push_notification/static/description/assets/misc/pictures.png differ diff --git a/mail_push_notification/static/description/assets/misc/pie-chart.png b/mail_push_notification/static/description/assets/misc/pie-chart.png new file mode 100755 index 000000000..426e05244 Binary files /dev/null and b/mail_push_notification/static/description/assets/misc/pie-chart.png differ diff --git a/mail_push_notification/static/description/assets/misc/right-arrow.png b/mail_push_notification/static/description/assets/misc/right-arrow.png new file mode 100755 index 000000000..730984a06 Binary files /dev/null and b/mail_push_notification/static/description/assets/misc/right-arrow.png differ diff --git a/mail_push_notification/static/description/assets/misc/star.png b/mail_push_notification/static/description/assets/misc/star.png new file mode 100755 index 000000000..2eb9ab29f Binary files /dev/null and b/mail_push_notification/static/description/assets/misc/star.png differ diff --git a/mail_push_notification/static/description/assets/misc/support.png b/mail_push_notification/static/description/assets/misc/support.png new file mode 100755 index 000000000..4f18b8b82 Binary files /dev/null and b/mail_push_notification/static/description/assets/misc/support.png differ diff --git a/mail_push_notification/static/description/assets/misc/whatsapp.png b/mail_push_notification/static/description/assets/misc/whatsapp.png new file mode 100755 index 000000000..d513a5356 Binary files /dev/null and b/mail_push_notification/static/description/assets/misc/whatsapp.png differ diff --git a/mail_push_notification/static/description/assets/modules/1.png b/mail_push_notification/static/description/assets/modules/1.png new file mode 100644 index 000000000..9de1176ad Binary files /dev/null and b/mail_push_notification/static/description/assets/modules/1.png differ diff --git a/mail_push_notification/static/description/assets/modules/2.jpg b/mail_push_notification/static/description/assets/modules/2.jpg new file mode 100644 index 000000000..22cfedd70 Binary files /dev/null and b/mail_push_notification/static/description/assets/modules/2.jpg differ diff --git a/mail_push_notification/static/description/assets/modules/3.png b/mail_push_notification/static/description/assets/modules/3.png new file mode 100644 index 000000000..9a9c416e0 Binary files /dev/null and b/mail_push_notification/static/description/assets/modules/3.png differ diff --git a/mail_push_notification/static/description/assets/modules/4.png b/mail_push_notification/static/description/assets/modules/4.png new file mode 100644 index 000000000..83e33258b Binary files /dev/null and b/mail_push_notification/static/description/assets/modules/4.png differ diff --git a/mail_push_notification/static/description/assets/modules/5.gif b/mail_push_notification/static/description/assets/modules/5.gif new file mode 100644 index 000000000..db040e0de Binary files /dev/null and b/mail_push_notification/static/description/assets/modules/5.gif differ diff --git a/mail_push_notification/static/description/assets/modules/6.png b/mail_push_notification/static/description/assets/modules/6.png new file mode 100644 index 000000000..42c89de23 Binary files /dev/null and b/mail_push_notification/static/description/assets/modules/6.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire1.png b/mail_push_notification/static/description/assets/screenshots/fire1.png new file mode 100644 index 000000000..af5a93010 Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire1.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire10.png b/mail_push_notification/static/description/assets/screenshots/fire10.png new file mode 100644 index 000000000..cd55f0b6b Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire10.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire11.png b/mail_push_notification/static/description/assets/screenshots/fire11.png new file mode 100644 index 000000000..ae76ac2c2 Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire11.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire12.png b/mail_push_notification/static/description/assets/screenshots/fire12.png new file mode 100644 index 000000000..b1a5a5a7b Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire12.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire13.png b/mail_push_notification/static/description/assets/screenshots/fire13.png new file mode 100644 index 000000000..1559c87c4 Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire13.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire14.png b/mail_push_notification/static/description/assets/screenshots/fire14.png new file mode 100644 index 000000000..3baca447a Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire14.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire15.png b/mail_push_notification/static/description/assets/screenshots/fire15.png new file mode 100644 index 000000000..4bc597737 Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire15.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire16.png b/mail_push_notification/static/description/assets/screenshots/fire16.png new file mode 100644 index 000000000..f4bf9618f Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire16.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire17.png b/mail_push_notification/static/description/assets/screenshots/fire17.png new file mode 100644 index 000000000..af1a562cd Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire17.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire18.png b/mail_push_notification/static/description/assets/screenshots/fire18.png new file mode 100644 index 000000000..52af5fe55 Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire18.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire19.png b/mail_push_notification/static/description/assets/screenshots/fire19.png new file mode 100644 index 000000000..e2554533e Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire19.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire2.png b/mail_push_notification/static/description/assets/screenshots/fire2.png new file mode 100644 index 000000000..06273b481 Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire2.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire20.png b/mail_push_notification/static/description/assets/screenshots/fire20.png new file mode 100644 index 000000000..7e2c2bf56 Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire20.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire21.png b/mail_push_notification/static/description/assets/screenshots/fire21.png new file mode 100644 index 000000000..13012d009 Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire21.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire22.png b/mail_push_notification/static/description/assets/screenshots/fire22.png new file mode 100644 index 000000000..82025445b Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire22.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire3.png b/mail_push_notification/static/description/assets/screenshots/fire3.png new file mode 100644 index 000000000..c80d8ceb6 Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire3.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire4.png b/mail_push_notification/static/description/assets/screenshots/fire4.png new file mode 100644 index 000000000..56838701a Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire4.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire5.png b/mail_push_notification/static/description/assets/screenshots/fire5.png new file mode 100644 index 000000000..1e5a8c458 Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire5.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire6.png b/mail_push_notification/static/description/assets/screenshots/fire6.png new file mode 100644 index 000000000..647c8f92e Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire6.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire7.png b/mail_push_notification/static/description/assets/screenshots/fire7.png new file mode 100644 index 000000000..947fead97 Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire7.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire8.png b/mail_push_notification/static/description/assets/screenshots/fire8.png new file mode 100644 index 000000000..c26950122 Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire8.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/fire9.png b/mail_push_notification/static/description/assets/screenshots/fire9.png new file mode 100644 index 000000000..1e3d6bb56 Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/fire9.png differ diff --git a/mail_push_notification/static/description/assets/screenshots/hero.gif b/mail_push_notification/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..66bdceede Binary files /dev/null and b/mail_push_notification/static/description/assets/screenshots/hero.gif differ diff --git a/mail_push_notification/static/description/banner.png b/mail_push_notification/static/description/banner.png new file mode 100644 index 000000000..918dd9434 Binary files /dev/null and b/mail_push_notification/static/description/banner.png differ diff --git a/mail_push_notification/static/description/icon.png b/mail_push_notification/static/description/icon.png new file mode 100644 index 000000000..a53464324 Binary files /dev/null and b/mail_push_notification/static/description/icon.png differ diff --git a/mail_push_notification/static/description/index.html b/mail_push_notification/static/description/index.html new file mode 100755 index 000000000..bf617f832 --- /dev/null +++ b/mail_push_notification/static/description/index.html @@ -0,0 +1,792 @@ +
+ +
+ +
+
+ Community +
+
+ Enterprise +
+
+ Odoo.sh +
+
+
+ +
+ +

+ Push Notification From ChatBox

+

+ Push Notification From ChatBox Provide Alerts To Users When They + Receive + New Message From The Chatter

+ + +
+ +
+ + +
+
+ +
+

+ Explore This + Module

+
+ + + + +
+
+ +
+

+ Overview +

+
+
+
+ Push Notification From ChatBox in Odoo provide instant alerts to users + when + they receive new messages within the platform. These real-time. They + work seamlessly across devices and integrate with other Odoo + applications. With Push Notification From ChatBox, users can respond + promptly + to important messages,improving communication efficiency. +
+ +
+ + + +
+
+ +
+

+ Features +

+
+
+
+
+ + Real-time Alerts: Users receive instant notifications on their devices (such as desktop or mobile) as soon as a new message arrives in their Odoo inbox. +
+
+ + Reduced Response Time: With instant notifications, users can respond promptly to important messages, improving communication efficiency and effectiveness. +
+
+ + Privacy and Security: The notifications are secure and respect user privacy, as they are confined within the Odoo environment. +
+
+
+
+ + Message Preview: Notifications typically include a preview of the message content, enabling users to quickly assess the urgency or relevance. +
+
+ + Compatible with both Odoo 16.0 Community and Enterprise Editions. +
+
+
+ + + +
+
+ +
+

+ Screenshots +

+
+
+
+ +
+

+ Firebase View

+

+ First go to Firebase + console + Create a Project if you don't have any project. +

+ +
+
+

+ Set the name for the project and Continue

+ +
+
+

+ Make sure that enabled the Google Analytics for this project + and click the Continue and Create the project

+ +
+
+

+ Then you need to create web app in that project for that click + the web app icon in the project like shown below

+ +
+
+

+ Set the name for the app and register the app

+ +
+
+

+ Here you can see all the details we need you can copy them and + after that select npm and click the Next Button

+ +
+
+ +

+ After that you can click Next Button for Install Firebase + CLI

+ +
+
+ +

+ After that click the Continue to console

+ +
+
+ +

+ After that you can see the app inside the project and click on + the setting icon of the app to see the details of that app

+ +
+
+

+ You can see the credentials(not server key and vapid) we need + in odoo in the General --> Your apps

+ +
+
+ +
+
+

+ You can create the server key we need in odoo.For that goto the + Cloud Messaging --> Cloud Messaging API (Legacy) --> 3 dots + -->Manage API in Google Cloud Console --> Enable the Cloud + Messaging

+ +
+
+ +
+
+

+ After that you can see the Server key in Cloud Messaging API + (Legacy)

+ +
+
+

+ Now we need to create a Vapid goto the Cloud Messaging --> Web + configuration --> Generate Key pair

+ +
+
+

+ After that you can see the public key of the Vap id Cloud + Messaging --> Web configuration

+ +
+
+

+ Configuration Settings +

+

+ Goto the Settings and enable the 'Enable Push Notification' + then you + can set the credential

+ +

+ Its very important that You must Allow the notification in + the web browser

+ +

+ After Allowing the notification access in the browser you can + click the "TEST CONNECTION" Button

+ +

+ Then you can see a notification on the system, and you can see + a green popup

+ +
+ +
+

+ Notification View

+

+ After that you can send message from the chatbox module or in + the discuss module

+ +
+
+

+ Notification View

+

+ Then you can see a popup notification in the other user and + when you click on that it will be redirected to the odoo + instance

+ +
+
+
+ + + +
+
+ +
+

+ Related + Products +

+
+
+
+ +
+
+ + + + +
+
+ +
+

+ Our Services +

+
+ +
+
+
+
+ +
+
+ Odoo + Customization
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Support
+
+ + +
+
+ +
+
+ Hire + Odoo + Developer
+
+ +
+
+ +
+
+ Odoo + Integration
+
+ +
+
+ +
+
+ Odoo + Migration
+
+ + +
+
+ +
+
+ Odoo + Consultancy
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Licensing Consultancy
+
+
+ +
+ + + + + +
+
+ +
+

+ Our + Industries +

+
+ +
+
+
+
+ +
+ Trading +
+

+ Easily procure + and + sell your products

+
+
+ +
+
+ +
+ POS +
+

+ Easy + configuration + and convivial experience

+
+
+ +
+
+ +
+ Education +
+

+ A platform for + educational management

+
+
+ +
+
+ +
+ Manufacturing +
+

+ Plan, track and + schedule your operations

+
+
+ +
+
+ +
+ E-commerce & Website +
+

+ Mobile + friendly, + awe-inspiring product pages

+
+
+ +
+
+ +
+ Service Management +
+

+ Keep track of + services and invoice

+
+
+ +
+
+ +
+ Restaurant +
+

+ Run your bar or + restaurant methodically

+
+
+ +
+
+ +
+ Hotel Management +
+

+ An + all-inclusive + hotel management application

+
+
+
+
+ + + + +
+
+ +
+

+ Support +

+
+
+
+
+
+
+ +
+
+

Need Help?

+

Got questions or need help? + Get in touch.

+ +

+ odoo@cybrosys.com

+
+
+
+
+
+
+
+ +
+
+

WhatsApp

+

Say hi to us on WhatsApp!

+ +

+ +91 86068 + 27707

+
+
+
+
+
+
+
+ +
+
+
+ diff --git a/mail_push_notification/static/src/js/firebase.js b/mail_push_notification/static/src/js/firebase.js new file mode 100755 index 000000000..ebbdb2b9b --- /dev/null +++ b/mail_push_notification/static/src/js/firebase.js @@ -0,0 +1,100 @@ +/** + * Odoo module for handling Firebase push notifications. + * + * This module initializes Firebase messaging and handles push notifications + * for the current session's company. It also registers the service worker for + * handling notifications if the company has push notifications enabled. + * + * @module mail_push_notification + */ +odoo.define("mail_push_notification.Firebase", function (require) { + "use strict"; + var ajax = require('web.ajax'); + var rpc = require("web.rpc"); + var session = require('web.session'); + var vapid = ''; + var firebaseConfig = {}; + var push_notification = false; + /** + * Sends an RPC query to retrieve push notification settings for the current company. + * + * @function + * @returns {Promise} A promise that resolves with the push notification settings. + */ + rpc.query({ + model: 'res.company', + method: 'search_read', + fields: ['push_notification'], + domain: [['id', '=', session.company_id]] + }, { async: false }).then(function (data) { + if (data) { + _.each(data, function (company) { + if (company.push_notification) { + push_notification = true; + if ("serviceWorker" in navigator) { + navigator.serviceWorker.register("/firebase-messaging-sw.js").then(function () {}); + } + } + }); + } + }); + ajax.jsonRpc("/firebase_config_details", 'call', {}).then(function (data) { + if (data) { + var json = JSON.parse(data); + vapid = json.vapid; + firebaseConfig = json.config; + /** + * Initializes Firebase messaging and sets up event listeners for incoming messages. + * + * @function + */ + firebase.initializeApp(firebaseConfig); + const messaging = firebase.messaging(); + /** + * Handles incoming push notification messages. + * + * @function + * @param {Object} payload - The notification payload. + */ + messaging.onMessage((payload) => { + const notificationOptions = { + body: payload.notification.body, + }; + let notification = payload.notification; + navigator.serviceWorker.getRegistrations().then((registration) => { + registration[0].showNotification(notification.title, notificationOptions); + }); + }); + /** + * Requests permission for receiving push notifications and retrieves the registration token. + * + * @function + */ + messaging.requestPermission().then(function () { + /** + * Retrieves the registration token and sends it to the server for subscription. + * + * @function + * @param {string} vapidKey - The VAPID key for authentication. + */ + messaging.getToken({ vapidKey: vapid }).then((currentToken) => { + if (currentToken) { + /** + * Sends a POST request to the server with the registration token. + * + * @function + * @param {string} token - The registration token. + */ + $.post("/push_notification", { + name: currentToken + }); + } else { + console.log('No registration token found'); + } + }).catch((err) => { + console.log('There is an error has occurred while attempting to retrieve the token.', err); + }); + }); + } + }); +}); diff --git a/mail_push_notification/views/res_config_settings_views.xml b/mail_push_notification/views/res_config_settings_views.xml new file mode 100755 index 000000000..ee390b0ee --- /dev/null +++ b/mail_push_notification/views/res_config_settings_views.xml @@ -0,0 +1,112 @@ + + + + + + res.config.settings.view.form.inherit.mail.push.notification + + res.config.settings + + + +
+

Firebase Push Notifications

+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+