mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
New module web_notify
This technical module allows you to send instant notification messages from the server to the user in live.
This commit is contained in:
committed by
Jairo Llopis
parent
08c16707ed
commit
f916f2c9f1
1
web_notify/models/__init__.py
Normal file
1
web_notify/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import res_users
|
||||
32
web_notify/models/res_users.py
Normal file
32
web_notify/models/res_users.py
Normal file
@@ -0,0 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import api, models, _
|
||||
|
||||
|
||||
class ResUsers(models.Model):
|
||||
|
||||
_inherit = 'res.users'
|
||||
|
||||
@api.multi
|
||||
def notify_info(self, message, title=None, sticky=False):
|
||||
title = title or _('Information')
|
||||
self._notify_channel('notify_info', message, title, sticky)
|
||||
|
||||
@api.multi
|
||||
def notify_warning(self, message, title=None, sticky=False):
|
||||
title = title or _('Warning')
|
||||
self._notify_channel('notify_warning', message, title, sticky)
|
||||
|
||||
@api.multi
|
||||
def _notify_channel(self, channel_name_prefix, message, title, sticky):
|
||||
notification = {
|
||||
'message': message,
|
||||
'title': title,
|
||||
'sticky': sticky
|
||||
}
|
||||
bus_bus = self.env['bus.bus']
|
||||
for record in self:
|
||||
channel_name = channel_name_prefix + "_%s" % record.id
|
||||
bus_bus.sendone(channel_name, notification)
|
||||
Reference in New Issue
Block a user