From 071aa38b4eb42ef8acabd5258b752acd26ce15e4 Mon Sep 17 00:00:00 2001 From: Yannick Tivisse Date: Mon, 8 Feb 2016 15:04:01 +0100 Subject: [PATCH] [FIX] web: avoid infinite pending state in case of RPC call fail If the RPC fails, the deferred is never resolved nor rejected, so the deferred given by willStart will stay in a 'pending' state As the deferred is expected to be resolved or rejected to launch the systray to continue, we have to catch this case too. --- .../static/src/js/widgets/switch_company_menu.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/addons/web/static/src/js/widgets/switch_company_menu.js b/addons/web/static/src/js/widgets/switch_company_menu.js index 45906c10397..67b3ae57b6c 100644 --- a/addons/web/static/src/js/widgets/switch_company_menu.js +++ b/addons/web/static/src/js/widgets/switch_company_menu.js @@ -19,6 +19,8 @@ odoo.define('web.SwitchCompanyMenu', function(require) { } else { def.reject(); } + }).fail(function(){ + def.reject(); }); return $.when(this._super(), def); }, @@ -27,7 +29,10 @@ odoo.define('web.SwitchCompanyMenu', function(require) { this.$el.on('click', '.dropdown-menu li a[data-menu]', function(ev) { ev.preventDefault(); - self['on_menu_company']($(this)); + var company_id = $(ev.currentTarget).data('company-id'); + new Model('res.users').call('write', [[session.uid], {'company_id': company_id}]).then(function() { + location.reload(); + }); }); self.$('.oe_topbar_name').text(self.current_company[1]); @@ -45,12 +50,6 @@ odoo.define('web.SwitchCompanyMenu', function(require) { self.$('.dropdown-menu').html(companies_list); return this._super(); }, - on_menu_company: function(selected) { - var company_id = selected.data('company-id'); - new Model('res.users').call('write', [[session.uid], {'company_id': company_id}]).then(function() { - location.reload(); - }); - }, }); SystrayMenu.Items.push(SwitchCompanyMenu);