openerp.portal_anonymous = function(instance) {

    instance.web.Session.include({
        load_translations: function() {
            var self = this;
            // browser_lang can contain 'xx' or 'xx_XX'
            // we use the 'xx' to find matching languages installed in the DB
            var browser_lang = (navigator.language || navigator.userLanguage).replace('-', '_');
            // By default for anonymous session.user_context.lang === 'en_US',
            // so do nothing if browser_lang is contained in 'en_US' (like 'en' or 'en_US')
            if (this.username === 'anonymous' && this.user_context.lang.indexOf(browser_lang) === -1) {
                return (new instance.web.Model('res.lang')).query(['code', 'iso_code'])
                    .filter([['code', 'like', browser_lang.substring(0, 2).toLowerCase()]]).all()
                .then(function(langs) {
                    // If langs is empty (OpenERP doesn't support the language),
                    // then don't change session.user_context.lang
                    if (langs.length > 0) {
                        // Try to get the right user preference in the browser, else
                        // get the shortest language returned ('xx' country code) or
                        // just the first one
                        var l = _.filter(langs, function(lang) { return lang.code === browser_lang || lang.iso_code === browser_lang; });
                        if (!_.isEmpty(l)) {
                            self.user_context.lang = l[0].code;
                        } else {
                            l = _.filter(langs, function(lang) {
                                return lang.iso_code === _.pluck(langs, 'iso_code')
                                    .sort(function(a, b) {
                                        return a.length - b.length;
                                    })[0];
                            });
                            self.user_context.lang = l[0].code;
                        }
                    }
                    return self.rpc('/web/webclient/translations', { mods: self.module_list, lang: self.user_context.lang }).done(function(trans) {
                        instance.web._t.database.set_bundle(trans);
                    });
                });
            }
            return this._super();
        },
    });

    instance.web.Login.include({
        start: function() {
            var self = this;
            return $.when(this._super()).then(function() {
                if (!self.session.session_is_valid() && !(self.params.token || self.params.login)) {
                    self.remember_credentials = false;
                    // XXX get login/pass from server (via a rpc call) ?
                    return self.do_login(self.selected_db, 'anonymous', 'anonymous');
                }
            });
        },
    });

    instance.web.UserMenu.include({
        init: function(parent) {
            this._super(parent);
            if (this.session.username == 'anonymous') {
                this.template = 'UserMenu.portal_anonymous';
                this.do_update = function() {};     // avoid change of avatar
            }
        },
        start: function() {
            var self = this;
            this._super.apply(this, arguments);
            this.$el.find('a.login').click(function() {
                var p = self.getParent();
                var am = p.action_manager;
                p.$el.find('.oe_leftbar, .oe_topbar').hide();
                self.session.session_logout().done(function () {
                    am.do_action({
                        type:'ir.actions.client',
                        tag:'login',
                        target: 'current',
                        params: {
                            login_successful: function() {
                                am.do_action("reload");
                            }
                        }
                    });
                });
            });
        }
    });

    instance.web.WebClient.include({
        check_timezone: function() {
            if (this.session.username !== 'anonymous') {
                return this._super.apply(this, arguments);
            }
            return false;
        },
    });

};

@@ -2434,109 +2434,17 @@
     
-var self = this;%0A            return $.when(this._super()).then(function() %7B%0A                if (!self
+if (!this
 .ses
@@ -2472,20 +2472,20 @@
 () && !(
-self
+this
 .params.
@@ -2493,20 +2493,20 @@
 oken %7C%7C 
-self
+this
 .params.
@@ -2531,24 +2531,53 @@
         
-    self
+this.$el.hide();%0A                this
 .remembe
@@ -2615,20 +2615,16 @@
         
- 
-   
 // XXX g
@@ -2684,31 +2684,27 @@
         
-    
 return 
-self
+this
 .do_logi
@@ -2705,20 +2705,20 @@
 o_login(
-self
+this
 .selecte
@@ -2754,38 +2754,43 @@
 ');%0A            
-    %7D%0A
+%7D else %7B%0A  
             %7D);%0A
@@ -2777,35 +2777,90 @@
 %7B%0A              
-%7D);
+  return this._super.apply(this, arguments);%0A            %7D
 %0A        %7D,%0A    

Fix anonymous login flickering