[IMP] web: improve act_url

By default, Chrome browser will block pop-up windows which will block
all actions from type act_url with a different target than 'self' (i.e.
'_blank').
This commit adds a check when such an action is called and sends a
warning in the web client when it fails to open. This mimics the
behaviour already present for the report actions.
This commit is contained in:
Rémi Rahir
2018-05-24 15:47:43 +02:00
parent 2a3048316e
commit 58acf26ea4
@@ -22,6 +22,7 @@ var framework = require('web.framework');
var pyeval = require('web.pyeval');
var Widget = require('web.Widget');
var _t = core._t;
var ActionManager = Widget.extend({
className: 'o_content',
custom_events: {
@@ -547,7 +548,13 @@ var ActionManager = Widget.extend({
framework.redirect(url);
return $.Deferred();
} else {
window.open(url, '_blank');
var w = window.open(url, '_blank');
        if (!w || w.closed || typeof w.closed === 'undefined') {
            var message = _t('A popup window was blocked. You ' +
'may need to change your browser settings to allow ' +
'popup windows for this page.');
this.do_warn(_t('Warning'), message, true);
        }
}
options.on_close();