[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.
This commit is contained in:
Yannick Tivisse
2016-02-08 15:04:01 +01:00
parent 46e925aa9f
commit 071aa38b4e
@@ -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);