From 95ef46096110512117a7b7dd9bc797732be36b26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Lef=C3=A8vre?= Date: Tue, 29 Jan 2019 09:36:00 +0000 Subject: [FIX] mail: don't trigger if mail bus is undefined Steps to reproduce the bug: 1. open an app such that there is a breadcrumb (e.g. an employee form view) 2. create a chat window with a user 3. click on the expand button to open the chat in Discuss 4. unsubscribe from the thread 5. click on the breadcrumb to go back => Traceback When expanding the chat window to open Discuss, it registers a callback which triggers an event on the mail bus. This callback is called when clicking on the breadcrumb. Because the channel was left, any related chat window is destroyed. Since the widget is destroyed, it has no parent, so any service call returns `undefined`, hence `getMailBus` returns `undefined`. Fix: check if mailbus exists before triggering. closes odoo/odoo#30640 --- addons/mail/static/src/js/thread_windows/thread_window.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'addons/mail/static/src/js/thread_windows/thread_window.js') diff --git a/addons/mail/static/src/js/thread_windows/thread_window.js b/addons/mail/static/src/js/thread_windows/thread_window.js index 37cd673b053..49f4abf7f06 100644 --- a/addons/mail/static/src/js/thread_windows/thread_window.js +++ b/addons/mail/static/src/js/thread_windows/thread_window.js @@ -276,8 +276,10 @@ var ThreadWindow = AbstractThreadWindow.extend({ clear_breadcrumbs: false, active_id: this.hasThread() ? this._getThreadID() : undefined, on_reverse_breadcrumb: function () { - self.call('mail_service', 'getMailBus') - .trigger('discuss_open', false); + var mailBus = self.call('mail_service', 'getMailBus'); + if (mailBus) { + mailBus.trigger('discuss_open', false); + } }, }); } -- cgit v1.2.3