diff --git a/web_notify/__manifest__.py b/web_notify/__manifest__.py index 858c3be9..9b152fe6 100644 --- a/web_notify/__manifest__.py +++ b/web_notify/__manifest__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2016 ACSONE SA/NV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -6,7 +5,7 @@ 'name': 'Web Notify', 'summary': """ Send notification messages to user""", - 'version': '10.0.1.0.0', + 'version': '11.0.1.0.0', 'description': 'Web Notify', 'license': 'AGPL-3', 'author': 'ACSONE SA/NV,Odoo Community Association (OCA)', diff --git a/web_notify/models/res_users.py b/web_notify/models/res_users.py index 29f0eca1..82563eae 100644 --- a/web_notify/models/res_users.py +++ b/web_notify/models/res_users.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2016 ACSONE SA/NV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/web_notify/static/src/js/web_client.js b/web_notify/static/src/js/web_client.js index 1ee99224..739251c8 100644 --- a/web_notify/static/src/js/web_client.js +++ b/web_notify/static/src/js/web_client.js @@ -3,24 +3,18 @@ odoo.define('web_notify.WebClient', function (require) { var WebClient = require('web.WebClient'); var base_bus = require('bus.bus'); +var session = require('web.session'); + WebClient.include({ - init: function(parent, client_options){ - this._super(parent, client_options); - }, show_application: function() { var res = this._super(); this.start_polling(); return res }, - on_logout: function() { - var self = this; - base_bus.bus.off('notification', this, this.bus_notification); - this._super(); - }, start_polling: function() { - this.channel_warning = 'notify_warning_' + this.session.uid; - this.channel_info = 'notify_info_' + this.session.uid; + this.channel_warning = 'notify_warning_' + session.uid; + this.channel_info = 'notify_info_' + session.uid; base_bus.bus.add_channel(this.channel_warning); base_bus.bus.add_channel(this.channel_info); base_bus.bus.on('notification', this, this.bus_notification); @@ -33,7 +27,7 @@ WebClient.include({ var message = notification[1]; if (channel === self.channel_warning) { self.on_message_warning(message); - } else if (channel == self.channel_info) { + } else if (channel === self.channel_info) { self.on_message_info(message); } }); diff --git a/web_notify/tests/test_res_users.py b/web_notify/tests/test_res_users.py index 72416d5e..80c26042 100644 --- a/web_notify/tests/test_res_users.py +++ b/web_notify/tests/test_res_users.py @@ -1,9 +1,9 @@ -# -*- coding: utf-8 -*- # Copyright 2016 ACSONE SA/NV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo.tests import common from odoo.addons.bus.models.bus import json_dump +import json import mock @@ -16,13 +16,11 @@ class TestResUsers(common.TransactionCase): json_dump(self.env.user.notify_info_channel_name)) ] existing = bus_bus.search(domain) - self.env.user.notify_info( - message='message', title='title', sticky=True) + test_msg = {'message': 'message', 'title': 'title', 'sticky': True} + self.env.user.notify_info(**test_msg) news = bus_bus.search(domain) - existing self.assertEqual(1, len(news)) - self.assertEqual( - '{"message":"message","sticky":true,"title":"title"}', - news.message) + self.assertEqual(test_msg, json.loads(news.message)) def test_notify_warning(self): bus_bus = self.env['bus.bus'] @@ -31,13 +29,11 @@ class TestResUsers(common.TransactionCase): json_dump(self.env.user.notify_warning_channel_name)) ] existing = bus_bus.search(domain) - self.env.user.notify_warning( - message='message', title='title', sticky=True) + test_msg = {'message': 'message', 'title': 'title', 'sticky': True} + self.env.user.notify_warning(**test_msg) news = bus_bus.search(domain) - existing self.assertEqual(1, len(news)) - self.assertEqual( - '{"message":"message","sticky":true,"title":"title"}', - news.message) + self.assertEqual(test_msg, json.loads(news.message)) def test_notify_many(self): # check that the notification of a list of users is done with diff --git a/web_notify/views/web_notify.xml b/web_notify/views/web_notify.xml index b85d2e6f..5dc3795f 100644 --- a/web_notify/views/web_notify.xml +++ b/web_notify/views/web_notify.xml @@ -1,7 +1,7 @@ -