mirror of https://github.com/OCA/web.git
[MIG] web_notify: Migrated in v17
parent
decbb9173f
commit
51412c2cc8
|
@ -151,6 +151,9 @@ Contributors
|
||||||
|
|
||||||
- David Vidal
|
- David Vidal
|
||||||
|
|
||||||
|
- Nikul Chaudhary <nchaudhary@opensourceintegrators.com>
|
||||||
|
- Tris Doan <tridm@trobz.com>
|
||||||
|
|
||||||
Maintainers
|
Maintainers
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"name": "Web Notify",
|
"name": "Web Notify",
|
||||||
"summary": """
|
"summary": """
|
||||||
Send notification messages to user""",
|
Send notification messages to user""",
|
||||||
"version": "16.0.2.0.1",
|
"version": "17.0.1.0.0",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"author": "ACSONE SA/NV," "AdaptiveCity," "Odoo Community Association (OCA)",
|
"author": "ACSONE SA/NV," "AdaptiveCity," "Odoo Community Association (OCA)",
|
||||||
"development_status": "Production/Stable",
|
"development_status": "Production/Stable",
|
||||||
|
|
|
@ -5,3 +5,5 @@
|
||||||
- Kevin Khao \<<kevin.khao@akretion.com>\>
|
- Kevin Khao \<<kevin.khao@akretion.com>\>
|
||||||
- [Tecnativa](https://www.tecnativa.com):
|
- [Tecnativa](https://www.tecnativa.com):
|
||||||
- David Vidal
|
- David Vidal
|
||||||
|
- Nikul Chaudhary \<<nchaudhary@opensourceintegrators.com>\>
|
||||||
|
- Tris Doan \<<tridm@trobz.com>\>
|
||||||
|
|
|
@ -479,6 +479,8 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||||
<li>David Vidal</li>
|
<li>David Vidal</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
<li>Nikul Chaudhary <<a class="reference external" href="mailto:nchaudhary@opensourceintegrators.com">nchaudhary@opensourceintegrators.com</a>></li>
|
||||||
|
<li>Tris Doan <<a class="reference external" href="mailto:tridm@trobz.com">tridm@trobz.com</a>></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/** @odoo-module */
|
/** @odoo-module */
|
||||||
import {Notification} from "@web/core/notifications/notification";
|
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: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/** @odoo-module **/
|
/** @odoo-module **/
|
||||||
import {Markup} from "web.utils";
|
|
||||||
|
import {markup} from "@odoo/owl";
|
||||||
import {browser} from "@web/core/browser/browser";
|
import {browser} from "@web/core/browser/browser";
|
||||||
import {registry} from "@web/core/registry";
|
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,
|
title: notif.title,
|
||||||
type: notif.type,
|
type: notif.type,
|
||||||
sticky: notif.sticky,
|
sticky: notif.sticky,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from odoo import exceptions
|
from odoo import SUPERUSER_ID, exceptions
|
||||||
from odoo.tests import common
|
from odoo.tests import common
|
||||||
|
|
||||||
from ..models.res_users import DANGER, DEFAULT, INFO, SUCCESS, WARNING
|
from ..models.res_users import DANGER, DEFAULT, INFO, SUCCESS, WARNING
|
||||||
|
@ -22,6 +22,7 @@ class TestResUsers(common.TransactionCase):
|
||||||
"params": {},
|
"params": {},
|
||||||
}
|
}
|
||||||
self.env.user.notify_success(**test_msg)
|
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
|
news = bus_bus.search(domain) - existing
|
||||||
self.assertEqual(1, len(news))
|
self.assertEqual(1, len(news))
|
||||||
test_msg.update({"type": SUCCESS})
|
test_msg.update({"type": SUCCESS})
|
||||||
|
@ -40,6 +41,7 @@ class TestResUsers(common.TransactionCase):
|
||||||
"params": {},
|
"params": {},
|
||||||
}
|
}
|
||||||
self.env.user.notify_danger(**test_msg)
|
self.env.user.notify_danger(**test_msg)
|
||||||
|
self.env.cr.precommit.run()
|
||||||
news = bus_bus.search(domain) - existing
|
news = bus_bus.search(domain) - existing
|
||||||
self.assertEqual(1, len(news))
|
self.assertEqual(1, len(news))
|
||||||
test_msg.update({"type": DANGER})
|
test_msg.update({"type": DANGER})
|
||||||
|
@ -58,6 +60,7 @@ class TestResUsers(common.TransactionCase):
|
||||||
"params": {},
|
"params": {},
|
||||||
}
|
}
|
||||||
self.env.user.notify_warning(**test_msg)
|
self.env.user.notify_warning(**test_msg)
|
||||||
|
self.env.cr.precommit.run()
|
||||||
news = bus_bus.search(domain) - existing
|
news = bus_bus.search(domain) - existing
|
||||||
self.assertEqual(1, len(news))
|
self.assertEqual(1, len(news))
|
||||||
test_msg.update({"type": WARNING})
|
test_msg.update({"type": WARNING})
|
||||||
|
@ -76,6 +79,7 @@ class TestResUsers(common.TransactionCase):
|
||||||
"params": {},
|
"params": {},
|
||||||
}
|
}
|
||||||
self.env.user.notify_info(**test_msg)
|
self.env.user.notify_info(**test_msg)
|
||||||
|
self.env.cr.precommit.run()
|
||||||
news = bus_bus.search(domain) - existing
|
news = bus_bus.search(domain) - existing
|
||||||
self.assertEqual(1, len(news))
|
self.assertEqual(1, len(news))
|
||||||
test_msg.update({"type": INFO})
|
test_msg.update({"type": INFO})
|
||||||
|
@ -94,6 +98,7 @@ class TestResUsers(common.TransactionCase):
|
||||||
"params": {},
|
"params": {},
|
||||||
}
|
}
|
||||||
self.env.user.notify_default(**test_msg)
|
self.env.user.notify_default(**test_msg)
|
||||||
|
self.env.cr.precommit.run()
|
||||||
news = bus_bus.search(domain) - existing
|
news = bus_bus.search(domain) - existing
|
||||||
self.assertEqual(1, len(news))
|
self.assertEqual(1, len(news))
|
||||||
test_msg.update({"type": DEFAULT})
|
test_msg.update({"type": DEFAULT})
|
||||||
|
@ -114,6 +119,12 @@ class TestResUsers(common.TransactionCase):
|
||||||
with self.assertRaises(exceptions.UserError):
|
with self.assertRaises(exceptions.UserError):
|
||||||
other_user_model.browse(self.env.uid).notify_info(message="hello")
|
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):
|
def test_notify_admin_allowed_other_user(self):
|
||||||
other_user = self.env.ref("base.user_demo")
|
other_user = self.env.ref("base.user_demo")
|
||||||
other_user.notify_info(message="hello")
|
other_user.notify_info(message="hello")
|
||||||
|
|
Loading…
Reference in New Issue