[FIX] failure to switch view due to switching to a non-existant view should not crash...
authorXavier Morel <xmo@openerp.com>
Fri, 9 Dec 2011 14:46:38 +0000 (15:46 +0100)
committerXavier Morel <xmo@openerp.com>
Fri, 9 Dec 2011 14:46:38 +0000 (15:46 +0100)
bzr revid: xmo@openerp.com-20111209144638-ppoxxlcn19sezyri

1  2 
addons/web/static/src/js/views.js

@@@ -251,7 -255,7 +255,7 @@@ session.web.ViewManager =  session.web.
              this.views_history.push(view_type);
          }
          this.active_view = view_type;
-         var view = this.views[view_type];
 -        
++
          if (!view.controller) {
              // Lazy loading of views
              var controllerclass = this.registry.get_object(view_type);
@@@ -494,32 -498,33 +498,31 @@@ session.web.ViewManagerAction = session
      },
      on_mode_switch: function (view_type, no_store) {
          var self = this;
-         var switched = $.when(this._super(view_type, no_store)).then(function () {
 -    
 -        var switched = $.when(this._super(view_type, no_store)).pipe(function () {
++
++        return $.when(this._super(view_type, no_store)).then(function () {
+             self.shortcut_check(self.views[view_type]);
++
              self.$element.find('.oe-view-manager-logs:first')
                  .addClass('oe-folded').removeClass('oe-has-more')
                  .find('ul').empty();
--        });
--        return $.when(
-                 switched,
-                 this.shortcut_check(this.views[view_type])
-             ).then(function() {
-                 var controller = self.views[self.active_view].controller,
-                     fvg = controller.fields_view,
-                     view_id = (fvg && fvg.view_id) || '--';
-                 self.$element.find('.oe_get_xml_view span').text(view_id);
-                 if (!self.action.name && fvg) {
-                     self.$element.find('.oe_view_title_text').text(fvg.arch.attrs.string || fvg.name);
-                 }
 -                switched
 -            ).pipe(function() {
 -                var controller = self.views[self.active_view].controller,
 -                    fvg = controller.fields_view,
 -                    view_id = (fvg && fvg.view_id) || '--';
 -                self.$element.find('.oe_get_xml_view span').text(view_id);
 -                if (!self.action.name && fvg) {
 -                    self.$element.find('.oe_view_title_text').text(fvg.arch.attrs.string || fvg.name);
 -                }
  
--                var $title = self.$element.find('.oe_view_title_text'),
--                    $search_prefix = $title.find('span.oe_searchable_view');
--                if (controller.searchable !== false) {
--                    if (!$search_prefix.length) {
--                        $title.prepend('<span class="oe_searchable_view">' + _t("Search: ") + '</span>');
--                    }
--                } else {
--                    $search_prefix.remove();
++            var controller = self.views[self.active_view].controller,
++                fvg = controller.fields_view,
++                view_id = (fvg && fvg.view_id) || '--';
++            self.$element.find('.oe_get_xml_view span').text(view_id);
++            if (!self.action.name && fvg) {
++                self.$element.find('.oe_view_title_text').text(fvg.arch.attrs.string || fvg.name);
++            }
++
++            var $title = self.$element.find('.oe_view_title_text'),
++                $search_prefix = $title.find('span.oe_searchable_view');
++            if (controller.searchable !== false) {
++                if (!$search_prefix.length) {
++                    $title.prepend('<span class="oe_searchable_view">' + _t("Search: ") + '</span>');
                  }
++            } else {
++                $search_prefix.remove();
++            }
          });
      },
      shortcut_check : function(view) {