web_notify: add feature to reload current view

This commit is contained in:
Guewen Baconnier
2018-06-27 14:39:47 +02:00
committed by Yannick Vaucher
parent b8e1337079
commit 8d3f2749e4
8 changed files with 138 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2016 ACSONE SA/NV
# Copyright 2018 Camptocamp
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models, _
@@ -23,23 +24,27 @@ class ResUsers(models.Model):
compute='_compute_channel_names')
@api.multi
def notify_info(self, message, title=None, sticky=False):
def notify_info(self, message, title=None, sticky=False,
show_reload=False):
title = title or _('Information')
self._notify_channel(
'notify_info_channel_name', message, title, sticky)
'notify_info_channel_name', message, title, sticky, show_reload)
@api.multi
def notify_warning(self, message, title=None, sticky=False):
def notify_warning(self, message, title=None, sticky=False,
show_reload=False):
title = title or _('Warning')
self._notify_channel(
'notify_warning_channel_name', message, title, sticky)
'notify_warning_channel_name', message, title, sticky, show_reload)
@api.multi
def _notify_channel(self, channel_name_field, message, title, sticky):
def _notify_channel(self, channel_name_field, message, title, sticky,
show_reload):
bus_message = {
'message': message,
'title': title,
'sticky': sticky
'sticky': sticky,
'show_reload': show_reload,
}
notifications = [(getattr(record, channel_name_field), bus_message)
for record in self]