From 28a68b6bc585fd92eea6b71b8007fd9751096e01 Mon Sep 17 00:00:00 2001 From: Swapnesh Shah Date: Mon, 27 Apr 2020 16:39:05 +0000 Subject: [PATCH] [FIX] odoo_referral: notify user if popup is blocked Before this, User was unaware of the fact that Popup might be blocked which due to which window won't be opened. With this commit, We notify users about that. closes odoo/odoo#51015 X-original-commit: 393f417ce0d437118fc1ba72f05caeeb42ca70f4 Signed-off-by: Yannick Tivisse (yti) --- addons/odoo_referral/static/src/js/systray.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/odoo_referral/static/src/js/systray.js b/addons/odoo_referral/static/src/js/systray.js index 4af107d8b7c..4b29fd36e61 100644 --- a/addons/odoo_referral/static/src/js/systray.js +++ b/addons/odoo_referral/static/src/js/systray.js @@ -1,9 +1,11 @@ odoo.define('systray.systray_odoo_referral', function (require) { "use strict"; + var core = require('web.core'); var localStorage = require('web.local_storage'); var SystrayMenu = require('web.SystrayMenu'); var Widget = require('web.Widget'); + var _t = core._t; var ActionMenu = Widget.extend({ template: 'systray_odoo_referral.gift_icon', events: { @@ -44,7 +46,13 @@ odoo.define('systray.systray_odoo_referral', function (require) { }).then(function (result) { localStorage.setItem('odoo_referral.has_clicked', 1); self.$('.o_notification_counter').text(''); - window.open(result.link, '_blank', 'noopener noreferrer'); + var w = window.open(result.link, '_blank', 'noreferrer noopener'); + if (!w || w.closed || typeof w.closed === 'undefined') { + var message = _t('A popup window has been blocked. You ' + + 'may need to change your browser settings to allow ' + + 'popup windows for this page.'); + self.do_warn(_t('Warning'), message, true); + } }); }, });