[FIX] anonymous: adapt to Login client action

bzr revid: chs@openerp.com-20120726161732-objtaoe2dk54c2in
This commit is contained in:
Christophe Simonis 2012-07-26 18:17:32 +02:00
parent 9128e37231
commit 5e7f132055
1 changed files with 10 additions and 19 deletions

View File

@ -1,29 +1,20 @@
openerp.anonymous = function(instance) {
instance.web.client_actions.add("login", "instance.web.Login");
instance.web.WebClient.include({
show_login: function() {
var self = this, _super = this._super;
this.login.load_db_list().then(function() {
var dblist = self.login._db_list;
instance.web.Login.include({
start: function() {
var self = this;
return $.when(this._super()).pipe(function() {
var dblist = self._db_list;
if (dblist && dblist.length === 1) {
self.login.remember_credentials = false;
self.remember_credentials = false;
// XXX get login/pass from server (via a rpc call) ?
self.login.do_login(dblist[0], 'anonymous', 'anonymous').fail(function() {
_super.apply(self, []);
});
} else {
_super.apply(self, []);
return self.do_login(dblist[0], 'anonymous', 'anonymous')
}
});
},
restart: function() {
return this.start();
}
});
instance.web.UserMenu.include({
init: function(parent) {
this._super(parent);
@ -39,8 +30,8 @@ openerp.anonymous = function(instance) {
var p = self.getParent();
var am = p.action_manager;
p.$element.find('.oe_leftbar').hide();
am.do_action({type:'ir.actions.client', tag:'login'});
am.inner_widget.on('login', p, p.restart);
am.do_action({type:'ir.actions.client', tag:'login', target: 'new'});
am.dialog_widget.on('login', p, p.restart);
});
}
});