[FIX] web: prevent traceback when double-clicking links in modals

Before this revision, double-clicking links in a modal triggered a
traceback. This is because the second click attempts to change the
active view while it is still being changed by the first click (more
precisely, the controller of the active view is undefined on the second
click).

This commit ensures that on_attach_callback is called only if the
controller is defined.

Steps to reproduce the issue fixed by this commit:

1. Open a sales order;
2. Click on a product line;
3. Double-click on the product.
This commit is contained in:
Khoi Nguyen
2017-07-19 11:00:39 +02:00
parent b63e22f50e
commit f889d3af82
@@ -53,7 +53,8 @@ var ViewManager = Widget.extend(ControlPanelMixin, {
*/
on_attach_callback: function() {
this.is_in_DOM = true;
if (this.active_view && this.active_view.controller.on_attach_callback) {
var controller = this.active_view && this.active_view.controller;
if (controller && this.active_view.controller.on_attach_callback) {
this.active_view.controller.on_attach_callback();
}
},