diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 38923d268cf..484c58ef2c4 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -195,10 +195,20 @@ openerp.web.Loading = openerp.web.Widget.extend(/** @lends openerp.web.Loading# init: function(parent, element_id) { this._super(parent, element_id); this.count = 0; + this.blocked_ui = false; this.session.on_rpc_request.add_first(this.on_rpc_event, 1); this.session.on_rpc_response.add_last(this.on_rpc_event, -1); }, on_rpc_event : function(increment) { + var self = this; + if (!this.count && increment === 1) { + // Block UI after 3s + this.long_running_timer = setTimeout(function () { + self.blocked_ui = true; + $.blockUI(); + }, 3000); + } + this.count += increment; if (this.count) { //this.$element.html(QWeb.render("Loading", {})); @@ -206,6 +216,12 @@ openerp.web.Loading = openerp.web.Widget.extend(/** @lends openerp.web.Loading# this.$element.show(); this.widget_parent.$element.addClass('loading'); } else { + clearTimeout(this.long_running_timer); + // Don't unblock if blocked by somebody else + if (self.blocked_ui) { + this.blocked_ui = false; + $.unblockUI(); + } this.$element.fadeOut(); this.widget_parent.$element.removeClass('loading'); }