[MIG] web_notify: Migration to 11.0

- Use the 'session' class of the JS Framework (session no lounger bound
to web client)
- Test change: compare emitted & received messages based on content, not
order. Using string comparison raises false positives.
pull/2948/head
Damien Bouvy 2017-10-29 16:08:20 +01:00 committed by trisdoan
parent 1f9a18e30a
commit 9810010400
11 changed files with 102 additions and 60 deletions

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 ACSONE SA/NV # Copyright 2016 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
@ -6,7 +5,7 @@
'name': 'Web Notify', 'name': 'Web Notify',
'summary': """ 'summary': """
Send notification messages to user""", Send notification messages to user""",
'version': '10.0.1.0.0', 'version': '11.0.1.0.0',
'description': 'Web Notify', 'description': 'Web Notify',
'license': 'AGPL-3', 'license': 'AGPL-3',
'author': 'ACSONE SA/NV,Odoo Community Association (OCA)', 'author': 'ACSONE SA/NV,Odoo Community Association (OCA)',

View File

@ -12,26 +12,28 @@ msgstr ""
"PO-Revision-Date: 2017-02-03 01:37+0000\n" "PO-Revision-Date: 2017-02-03 01:37+0000\n"
"Last-Translator: Niki Waibel <niki.waibel@gmail.com>, 2017\n" "Last-Translator: Niki Waibel <niki.waibel@gmail.com>, 2017\n"
"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" "Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n"
"Language: de\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
"Language: de\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: web_notify #. module: web_notify
#: code:addons/web_notify/models/res_users.py:27 #: code:addons/web_notify/models/res_users.py:26
#, python-format #, python-format
msgid "Information" msgid "Information"
msgstr "Information" msgstr "Information"
#. module: web_notify #. module: web_notify
#: model:ir.model.fields,field_description:web_notify.field_res_users_notify_info_channel_name #: model:ir.model.fields,field_description:web_notify.field_res_users_notify_info_channel_name
msgid "Notify info channel name" #, fuzzy
msgid "Notify Info Channel Name"
msgstr "Name des Informationen-Kanals" msgstr "Name des Informationen-Kanals"
#. module: web_notify #. module: web_notify
#: model:ir.model.fields,field_description:web_notify.field_res_users_notify_warning_channel_name #: model:ir.model.fields,field_description:web_notify.field_res_users_notify_warning_channel_name
msgid "Notify warning channel name" #, fuzzy
msgid "Notify Warning Channel Name"
msgstr "Name des Warnungen-Kanals" msgstr "Name des Warnungen-Kanals"
#. module: web_notify #. module: web_notify
@ -40,7 +42,7 @@ msgid "Users"
msgstr "Benutzer" msgstr "Benutzer"
#. module: web_notify #. module: web_notify
#: code:addons/web_notify/models/res_users.py:33 #: code:addons/web_notify/models/res_users.py:32
#, python-format #, python-format
msgid "Warning" msgid "Warning"
msgstr "Warnung" msgstr "Warnung"

View File

@ -12,26 +12,28 @@ msgstr ""
"PO-Revision-Date: 2016-12-23 02:13+0000\n" "PO-Revision-Date: 2016-12-23 02:13+0000\n"
"Last-Translator: Pedro M. Baeza <pedro.baeza@gmail.com>, 2016\n" "Last-Translator: Pedro M. Baeza <pedro.baeza@gmail.com>, 2016\n"
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" "Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n"
"Language: es\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: web_notify #. module: web_notify
#: code:addons/web_notify/models/res_users.py:27 #: code:addons/web_notify/models/res_users.py:26
#, python-format #, python-format
msgid "Information" msgid "Information"
msgstr "Información" msgstr "Información"
#. module: web_notify #. module: web_notify
#: model:ir.model.fields,field_description:web_notify.field_res_users_notify_info_channel_name #: model:ir.model.fields,field_description:web_notify.field_res_users_notify_info_channel_name
msgid "Notify info channel name" #, fuzzy
msgid "Notify Info Channel Name"
msgstr "Nombre del canal de información notificada" msgstr "Nombre del canal de información notificada"
#. module: web_notify #. module: web_notify
#: model:ir.model.fields,field_description:web_notify.field_res_users_notify_warning_channel_name #: model:ir.model.fields,field_description:web_notify.field_res_users_notify_warning_channel_name
msgid "Notify warning channel name" #, fuzzy
msgid "Notify Warning Channel Name"
msgstr "Nombre del canal de avisos notificados" msgstr "Nombre del canal de avisos notificados"
#. module: web_notify #. module: web_notify
@ -40,7 +42,7 @@ msgid "Users"
msgstr "Usuarios" msgstr "Usuarios"
#. module: web_notify #. module: web_notify
#: code:addons/web_notify/models/res_users.py:33 #: code:addons/web_notify/models/res_users.py:32
#, python-format #, python-format
msgid "Warning" msgid "Warning"
msgstr "Aviso" msgstr "Aviso"

View File

@ -12,26 +12,29 @@ msgstr ""
"PO-Revision-Date: 2017-04-28 18:03+0000\n" "PO-Revision-Date: 2017-04-28 18:03+0000\n"
"Last-Translator: Bole <bole@dajmi5.com>, 2017\n" "Last-Translator: Bole <bole@dajmi5.com>, 2017\n"
"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" "Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n"
"Language: hr\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
"Language: hr\n" "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
#. module: web_notify #. module: web_notify
#: code:addons/web_notify/models/res_users.py:27 #: code:addons/web_notify/models/res_users.py:26
#, python-format #, python-format
msgid "Information" msgid "Information"
msgstr "Informacija" msgstr "Informacija"
#. module: web_notify #. module: web_notify
#: model:ir.model.fields,field_description:web_notify.field_res_users_notify_info_channel_name #: model:ir.model.fields,field_description:web_notify.field_res_users_notify_info_channel_name
msgid "Notify info channel name" #, fuzzy
msgid "Notify Info Channel Name"
msgstr "Naziv kanala informacija" msgstr "Naziv kanala informacija"
#. module: web_notify #. module: web_notify
#: model:ir.model.fields,field_description:web_notify.field_res_users_notify_warning_channel_name #: model:ir.model.fields,field_description:web_notify.field_res_users_notify_warning_channel_name
msgid "Notify warning channel name" #, fuzzy
msgid "Notify Warning Channel Name"
msgstr "Naziv kanala upozorenja" msgstr "Naziv kanala upozorenja"
#. module: web_notify #. module: web_notify
@ -40,7 +43,7 @@ msgid "Users"
msgstr "Korisnici" msgstr "Korisnici"
#. module: web_notify #. module: web_notify
#: code:addons/web_notify/models/res_users.py:33 #: code:addons/web_notify/models/res_users.py:32
#, python-format #, python-format
msgid "Warning" msgid "Warning"
msgstr "Upozorenje" msgstr "Upozorenje"

View File

@ -11,27 +11,28 @@ msgstr ""
"POT-Creation-Date: 2017-07-13 16:07+0000\n" "POT-Creation-Date: 2017-07-13 16:07+0000\n"
"PO-Revision-Date: 2017-07-13 16:07+0000\n" "PO-Revision-Date: 2017-07-13 16:07+0000\n"
"Last-Translator: Peter Hageman <hageman.p@gmail.com>, 2017\n" "Last-Translator: Peter Hageman <hageman.p@gmail.com>, 2017\n"
"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/teams/23907/nl_NL/)\n" "Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/"
"teams/23907/nl_NL/)\n"
"Language: nl_NL\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
"Language: nl_NL\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: web_notify #. module: web_notify
#: code:addons/web_notify/models/res_users.py:27 #: code:addons/web_notify/models/res_users.py:26
#, python-format #, python-format
msgid "Information" msgid "Information"
msgstr "Informatie" msgstr "Informatie"
#. module: web_notify #. module: web_notify
#: model:ir.model.fields,field_description:web_notify.field_res_users_notify_info_channel_name #: model:ir.model.fields,field_description:web_notify.field_res_users_notify_info_channel_name
msgid "Notify info channel name" msgid "Notify Info Channel Name"
msgstr "" msgstr ""
#. module: web_notify #. module: web_notify
#: model:ir.model.fields,field_description:web_notify.field_res_users_notify_warning_channel_name #: model:ir.model.fields,field_description:web_notify.field_res_users_notify_warning_channel_name
msgid "Notify warning channel name" msgid "Notify Warning Channel Name"
msgstr "" msgstr ""
#. module: web_notify #. module: web_notify
@ -40,7 +41,7 @@ msgid "Users"
msgstr "Gebruikers" msgstr "Gebruikers"
#. module: web_notify #. module: web_notify
#: code:addons/web_notify/models/res_users.py:33 #: code:addons/web_notify/models/res_users.py:32
#, python-format #, python-format
msgid "Warning" msgid "Warning"
msgstr "Waarschuwing" msgstr "Waarschuwing"

View File

@ -10,28 +10,32 @@ msgstr ""
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-22 08:27+0000\n" "POT-Creation-Date: 2017-06-22 08:27+0000\n"
"PO-Revision-Date: 2017-06-22 08:27+0000\n" "PO-Revision-Date: 2017-06-22 08:27+0000\n"
"Last-Translator: Rodrigo de Almeida Sottomaior Macedo <rmsolucoeseminformatic4@gmail.com>, 2017\n" "Last-Translator: Rodrigo de Almeida Sottomaior Macedo "
"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n" "<rmsolucoeseminformatic4@gmail.com>, 2017\n"
"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/"
"teams/23907/pt_BR/)\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
"Language: pt_BR\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. module: web_notify #. module: web_notify
#: code:addons/web_notify/models/res_users.py:27 #: code:addons/web_notify/models/res_users.py:26
#, python-format #, python-format
msgid "Information" msgid "Information"
msgstr "Informação" msgstr "Informação"
#. module: web_notify #. module: web_notify
#: model:ir.model.fields,field_description:web_notify.field_res_users_notify_info_channel_name #: model:ir.model.fields,field_description:web_notify.field_res_users_notify_info_channel_name
msgid "Notify info channel name" #, fuzzy
msgid "Notify Info Channel Name"
msgstr "Notificar o nome do canal de informações" msgstr "Notificar o nome do canal de informações"
#. module: web_notify #. module: web_notify
#: model:ir.model.fields,field_description:web_notify.field_res_users_notify_warning_channel_name #: model:ir.model.fields,field_description:web_notify.field_res_users_notify_warning_channel_name
msgid "Notify warning channel name" #, fuzzy
msgid "Notify Warning Channel Name"
msgstr "Notificar o nome do canal de alerta" msgstr "Notificar o nome do canal de alerta"
#. module: web_notify #. module: web_notify
@ -40,7 +44,7 @@ msgid "Users"
msgstr "Usuários" msgstr "Usuários"
#. module: web_notify #. module: web_notify
#: code:addons/web_notify/models/res_users.py:33 #: code:addons/web_notify/models/res_users.py:32
#, python-format #, python-format
msgid "Warning" msgid "Warning"
msgstr "Alerta" msgstr "Alerta"

View File

@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_notify
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.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
#: code:addons/web_notify/models/res_users.py:26
#, python-format
msgid "Information"
msgstr ""
#. module: web_notify
#: model:ir.model.fields,field_description:web_notify.field_res_users_notify_info_channel_name
msgid "Notify Info Channel Name"
msgstr ""
#. module: web_notify
#: model:ir.model.fields,field_description:web_notify.field_res_users_notify_warning_channel_name
msgid "Notify Warning Channel Name"
msgstr ""
#. module: web_notify
#: model:ir.model,name:web_notify.model_res_users
msgid "Users"
msgstr ""
#. module: web_notify
#: code:addons/web_notify/models/res_users.py:32
#, python-format
msgid "Warning"
msgstr ""

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 ACSONE SA/NV # Copyright 2016 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

View File

@ -3,24 +3,18 @@ odoo.define('web_notify.WebClient', function (require) {
var WebClient = require('web.WebClient'); var WebClient = require('web.WebClient');
var base_bus = require('bus.bus'); var base_bus = require('bus.bus');
var session = require('web.session');
WebClient.include({ WebClient.include({
init: function(parent, client_options){
this._super(parent, client_options);
},
show_application: function() { show_application: function() {
var res = this._super(); var res = this._super();
this.start_polling(); this.start_polling();
return res return res
}, },
on_logout: function() {
var self = this;
base_bus.bus.off('notification', this, this.bus_notification);
this._super();
},
start_polling: function() { start_polling: function() {
this.channel_warning = 'notify_warning_' + this.session.uid; this.channel_warning = 'notify_warning_' + session.uid;
this.channel_info = 'notify_info_' + this.session.uid; this.channel_info = 'notify_info_' + session.uid;
base_bus.bus.add_channel(this.channel_warning); base_bus.bus.add_channel(this.channel_warning);
base_bus.bus.add_channel(this.channel_info); base_bus.bus.add_channel(this.channel_info);
base_bus.bus.on('notification', this, this.bus_notification); base_bus.bus.on('notification', this, this.bus_notification);
@ -33,7 +27,7 @@ WebClient.include({
var message = notification[1]; var message = notification[1];
if (channel === self.channel_warning) { if (channel === self.channel_warning) {
self.on_message_warning(message); self.on_message_warning(message);
} else if (channel == self.channel_info) { } else if (channel === self.channel_info) {
self.on_message_info(message); self.on_message_info(message);
} }
}); });

View File

@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright 2016 ACSONE SA/NV # Copyright 2016 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests import common from odoo.tests import common
from odoo.addons.bus.models.bus import json_dump from odoo.addons.bus.models.bus import json_dump
import json
import mock import mock
@ -16,13 +16,11 @@ class TestResUsers(common.TransactionCase):
json_dump(self.env.user.notify_info_channel_name)) json_dump(self.env.user.notify_info_channel_name))
] ]
existing = bus_bus.search(domain) existing = bus_bus.search(domain)
self.env.user.notify_info( test_msg = {'message': 'message', 'title': 'title', 'sticky': True}
message='message', title='title', sticky=True) self.env.user.notify_info(**test_msg)
news = bus_bus.search(domain) - existing news = bus_bus.search(domain) - existing
self.assertEqual(1, len(news)) self.assertEqual(1, len(news))
self.assertEqual( self.assertEqual(test_msg, json.loads(news.message))
'{"message":"message","sticky":true,"title":"title"}',
news.message)
def test_notify_warning(self): def test_notify_warning(self):
bus_bus = self.env['bus.bus'] bus_bus = self.env['bus.bus']
@ -31,13 +29,11 @@ class TestResUsers(common.TransactionCase):
json_dump(self.env.user.notify_warning_channel_name)) json_dump(self.env.user.notify_warning_channel_name))
] ]
existing = bus_bus.search(domain) existing = bus_bus.search(domain)
self.env.user.notify_warning( test_msg = {'message': 'message', 'title': 'title', 'sticky': True}
message='message', title='title', sticky=True) self.env.user.notify_warning(**test_msg)
news = bus_bus.search(domain) - existing news = bus_bus.search(domain) - existing
self.assertEqual(1, len(news)) self.assertEqual(1, len(news))
self.assertEqual( self.assertEqual(test_msg, json.loads(news.message))
'{"message":"message","sticky":true,"title":"title"}',
news.message)
def test_notify_many(self): def test_notify_many(self):
# check that the notification of a list of users is done with # check that the notification of a list of users is done with

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<data> <data>
<template id="assets_backend" name="web_noify assets" inherit_id="web.assets_backend"> <template id="assets_backend" name="web_notify assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside"> <xpath expr="." position="inside">
<script type="text/javascript" src="/web_notify/static/src/js/web_client.js"/> <script type="text/javascript" src="/web_notify/static/src/js/web_client.js"/>
</xpath> </xpath>