From 51412c2cc8fb2414fd02dc45b0439f88ad99cf52 Mon Sep 17 00:00:00 2001 From: Nikul-OSI Date: Fri, 16 Feb 2024 16:30:37 +0530 Subject: [PATCH] [MIG] web_notify: Migrated in v17 --- web_notify/README.rst | 3 +++ web_notify/__manifest__.py | 2 +- web_notify/readme/CONTRIBUTORS.md | 2 ++ web_notify/static/description/index.html | 2 ++ .../static/src/js/services/notification.esm.js | 4 ++-- .../src/js/services/notification_services.esm.js | 5 +++-- web_notify/tests/test_res_users.py | 13 ++++++++++++- 7 files changed, 25 insertions(+), 6 deletions(-) diff --git a/web_notify/README.rst b/web_notify/README.rst index a61830850..e675045d9 100644 --- a/web_notify/README.rst +++ b/web_notify/README.rst @@ -151,6 +151,9 @@ Contributors - David Vidal +- Nikul Chaudhary +- Tris Doan + Maintainers ----------- diff --git a/web_notify/__manifest__.py b/web_notify/__manifest__.py index 94ea4f7ba..0275191f2 100644 --- a/web_notify/__manifest__.py +++ b/web_notify/__manifest__.py @@ -6,7 +6,7 @@ "name": "Web Notify", "summary": """ Send notification messages to user""", - "version": "16.0.2.0.1", + "version": "17.0.1.0.0", "license": "AGPL-3", "author": "ACSONE SA/NV," "AdaptiveCity," "Odoo Community Association (OCA)", "development_status": "Production/Stable", diff --git a/web_notify/readme/CONTRIBUTORS.md b/web_notify/readme/CONTRIBUTORS.md index 97775e9a9..4a5d3a20c 100644 --- a/web_notify/readme/CONTRIBUTORS.md +++ b/web_notify/readme/CONTRIBUTORS.md @@ -5,3 +5,5 @@ - Kevin Khao \<\> - [Tecnativa](https://www.tecnativa.com): - David Vidal +- Nikul Chaudhary \<\> +- Tris Doan \<\> diff --git a/web_notify/static/description/index.html b/web_notify/static/description/index.html index 400b4fc53..0ef31fe30 100644 --- a/web_notify/static/description/index.html +++ b/web_notify/static/description/index.html @@ -479,6 +479,8 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
  • David Vidal
  • +
  • Nikul Chaudhary <nchaudhary@opensourceintegrators.com>
  • +
  • Tris Doan <tridm@trobz.com>
  • diff --git a/web_notify/static/src/js/services/notification.esm.js b/web_notify/static/src/js/services/notification.esm.js index 489faddd3..7f8c28136 100644 --- a/web_notify/static/src/js/services/notification.esm.js +++ b/web_notify/static/src/js/services/notification.esm.js @@ -1,8 +1,8 @@ /** @odoo-module */ import {Notification} from "@web/core/notifications/notification"; -import {patch} from "web.utils"; +import {patch} from "@web/core/utils/patch"; -patch(Notification.props, "webNotifyProps", { +patch(Notification.props, { type: { type: String, optional: true, diff --git a/web_notify/static/src/js/services/notification_services.esm.js b/web_notify/static/src/js/services/notification_services.esm.js index 491a72f65..c37cc174f 100644 --- a/web_notify/static/src/js/services/notification_services.esm.js +++ b/web_notify/static/src/js/services/notification_services.esm.js @@ -1,5 +1,6 @@ /** @odoo-module **/ -import {Markup} from "web.utils"; + +import {markup} from "@odoo/owl"; import {browser} from "@web/core/browser/browser"; import {registry} from "@web/core/registry"; @@ -34,7 +35,7 @@ export const webNotificationService = { }, ]; } - const notificationRemove = notification.add(Markup(notif.message), { + const notificationRemove = notification.add(markup(notif.message), { title: notif.title, type: notif.type, sticky: notif.sticky, diff --git a/web_notify/tests/test_res_users.py b/web_notify/tests/test_res_users.py index f05e6709a..6cae1b256 100644 --- a/web_notify/tests/test_res_users.py +++ b/web_notify/tests/test_res_users.py @@ -3,7 +3,7 @@ import json -from odoo import exceptions +from odoo import SUPERUSER_ID, exceptions from odoo.tests import common from ..models.res_users import DANGER, DEFAULT, INFO, SUCCESS, WARNING @@ -22,6 +22,7 @@ class TestResUsers(common.TransactionCase): "params": {}, } self.env.user.notify_success(**test_msg) + self.env.cr.precommit.run() # trigger the creation of bus.bus records news = bus_bus.search(domain) - existing self.assertEqual(1, len(news)) test_msg.update({"type": SUCCESS}) @@ -40,6 +41,7 @@ class TestResUsers(common.TransactionCase): "params": {}, } self.env.user.notify_danger(**test_msg) + self.env.cr.precommit.run() news = bus_bus.search(domain) - existing self.assertEqual(1, len(news)) test_msg.update({"type": DANGER}) @@ -58,6 +60,7 @@ class TestResUsers(common.TransactionCase): "params": {}, } self.env.user.notify_warning(**test_msg) + self.env.cr.precommit.run() news = bus_bus.search(domain) - existing self.assertEqual(1, len(news)) test_msg.update({"type": WARNING}) @@ -76,6 +79,7 @@ class TestResUsers(common.TransactionCase): "params": {}, } self.env.user.notify_info(**test_msg) + self.env.cr.precommit.run() news = bus_bus.search(domain) - existing self.assertEqual(1, len(news)) test_msg.update({"type": INFO}) @@ -94,6 +98,7 @@ class TestResUsers(common.TransactionCase): "params": {}, } self.env.user.notify_default(**test_msg) + self.env.cr.precommit.run() news = bus_bus.search(domain) - existing self.assertEqual(1, len(news)) test_msg.update({"type": DEFAULT}) @@ -114,6 +119,12 @@ class TestResUsers(common.TransactionCase): with self.assertRaises(exceptions.UserError): other_user_model.browse(self.env.uid).notify_info(message="hello") + # This method for SUPER user + other_user = self.env.ref("base.user_demo") + other_user_model = self.env["res.users"].with_user(other_user) + with self.assertRaises(exceptions.UserError): + other_user_model.browse(SUPERUSER_ID).notify_info(message="hello") + def test_notify_admin_allowed_other_user(self): other_user = self.env.ref("base.user_demo") other_user.notify_info(message="hello")