Skip to content
Snippets Groups Projects
Commit a444f9c8 authored by Alexandre Kühn's avatar Alexandre Kühn
Browse files

[FIX] mail: this.env.services.bus_service is undefined


Before this commit, a page reload or a redirect could raise following
error:

```
Uncaught (in promise) TypeError: this.env.services.bus_service is undefined
```

This happens due to `Messaging` model relying on `bus_service` in its
teardown method `_willDelete`. This is sometimes unsafe because the
bus service may not have been deployed yet.

Task-2468469

closes odoo/odoo#66818

Signed-off-by: default avatarSébastien Theys (seb) <seb@odoo.com>
parent 2c38dc6e
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,9 @@ function factory(dependencies) {
* @override
*/
_willDelete() {
this.env.services['bus_service'].off('window_focus', null, this._handleGlobalWindowFocus);
if (this.env.services['bus_service']) {
this.env.services['bus_service'].off('window_focus', null, this._handleGlobalWindowFocus);
}
return super._willDelete(...arguments);
}
......
......@@ -16,8 +16,10 @@ function factory(dependencies) {
* @override
*/
_willDelete() {
this.env.services['bus_service'].off('notification');
this.env.services['bus_service'].stopPolling();
if (this.env.services['bus_service']) {
this.env.services['bus_service'].off('notification');
this.env.services['bus_service'].stopPolling();
}
return super._willDelete(...arguments);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment