3
0
Fork 0

[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.
18.0
Damien Bouvy 2017-10-29 16:08:20 +01:00 committed by trisdoan
parent ed2e6f0ea2
commit 687baa82b4
11 changed files with 102 additions and 60 deletions

View File

@ -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)',

View File

@ -1,7 +1,7 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_notify
#
#
# Translators:
# Niki Waibel <niki.waibel@gmail.com>, 2017
msgid ""
@ -12,26 +12,28 @@ msgstr ""
"PO-Revision-Date: 2017-02-03 01:37+0000\n"
"Last-Translator: Niki Waibel <niki.waibel@gmail.com>, 2017\n"
"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: de\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: web_notify
#: code:addons/web_notify/models/res_users.py:27
#: code:addons/web_notify/models/res_users.py:26
#, python-format
msgid "Information"
msgstr "Information"
#. module: web_notify
#: 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"
#. module: web_notify
#: 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"
#. module: web_notify
@ -40,7 +42,7 @@ msgid "Users"
msgstr "Benutzer"
#. module: web_notify
#: code:addons/web_notify/models/res_users.py:33
#: code:addons/web_notify/models/res_users.py:32
#, python-format
msgid "Warning"
msgstr "Warnung"

View File

@ -1,7 +1,7 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_notify
#
#
# Translators:
# Pedro M. Baeza <pedro.baeza@gmail.com>, 2016
msgid ""
@ -12,26 +12,28 @@ msgstr ""
"PO-Revision-Date: 2016-12-23 02:13+0000\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: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: web_notify
#: code:addons/web_notify/models/res_users.py:27
#: code:addons/web_notify/models/res_users.py:26
#, python-format
msgid "Information"
msgstr "Información"
#. module: web_notify
#: 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"
#. module: web_notify
#: 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"
#. module: web_notify
@ -40,7 +42,7 @@ msgid "Users"
msgstr "Usuarios"
#. module: web_notify
#: code:addons/web_notify/models/res_users.py:33
#: code:addons/web_notify/models/res_users.py:32
#, python-format
msgid "Warning"
msgstr "Aviso"

View File

@ -1,7 +1,7 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_notify
#
#
# Translators:
# Bole <bole@dajmi5.com>, 2017
msgid ""
@ -12,26 +12,29 @@ msgstr ""
"PO-Revision-Date: 2017-04-28 18:03+0000\n"
"Last-Translator: Bole <bole@dajmi5.com>, 2017\n"
"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n"
"Language: hr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: hr\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"
"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"
#. module: web_notify
#: code:addons/web_notify/models/res_users.py:27
#: code:addons/web_notify/models/res_users.py:26
#, python-format
msgid "Information"
msgstr "Informacija"
#. module: web_notify
#: 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"
#. module: web_notify
#: 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"
#. module: web_notify
@ -40,7 +43,7 @@ msgid "Users"
msgstr "Korisnici"
#. module: web_notify
#: code:addons/web_notify/models/res_users.py:33
#: code:addons/web_notify/models/res_users.py:32
#, python-format
msgid "Warning"
msgstr "Upozorenje"

View File

@ -1,7 +1,7 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_notify
#
#
# Translators:
# Peter Hageman <hageman.p@gmail.com>, 2017
msgid ""
@ -11,27 +11,28 @@ msgstr ""
"POT-Creation-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"
"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"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: nl_NL\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: web_notify
#: code:addons/web_notify/models/res_users.py:27
#: code:addons/web_notify/models/res_users.py:26
#, python-format
msgid "Information"
msgstr "Informatie"
#. module: web_notify
#: 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 ""
#. module: web_notify
#: 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 ""
#. module: web_notify
@ -40,7 +41,7 @@ msgid "Users"
msgstr "Gebruikers"
#. module: web_notify
#: code:addons/web_notify/models/res_users.py:33
#: code:addons/web_notify/models/res_users.py:32
#, python-format
msgid "Warning"
msgstr "Waarschuwing"

View File

@ -1,7 +1,7 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_notify
#
#
# Translators:
# Rodrigo de Almeida Sottomaior Macedo <rmsolucoeseminformatic4@gmail.com>, 2017
msgid ""
@ -10,28 +10,32 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-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"
"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n"
"Last-Translator: Rodrigo de Almeida Sottomaior Macedo "
"<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"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: pt_BR\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. module: web_notify
#: code:addons/web_notify/models/res_users.py:27
#: code:addons/web_notify/models/res_users.py:26
#, python-format
msgid "Information"
msgstr "Informação"
#. module: web_notify
#: 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"
#. module: web_notify
#: 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"
#. module: web_notify
@ -40,7 +44,7 @@ msgid "Users"
msgstr "Usuários"
#. module: web_notify
#: code:addons/web_notify/models/res_users.py:33
#: code:addons/web_notify/models/res_users.py:32
#, python-format
msgid "Warning"
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
# 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 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);
}
});

View File

@ -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

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<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">
<script type="text/javascript" src="/web_notify/static/src/js/web_client.js"/>
</xpath>