diff options
| author | Yannick Tivisse <yti@odoo.com> | 2016-02-08 15:04:01 +0100 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2016-02-08 15:04:01 +0100 |
| commit | 071aa38b4eb42ef8acabd5258b752acd26ce15e4 (patch) | |
| tree | 4760d8713d5f89bedd83850d9c85d621e0b5cec9 /addons/web/static/src | |
| parent | 46e925aa9f7bdbff3fb062e26eb49025bbc0c570 (diff) | |
[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.
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/widgets/switch_company_menu.js | 13 |
1 files 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); |
