From 5e7b30e9968fe80d5cd7a8c43e916048046a9531 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 1 Feb 2012 16:44:42 +0100 Subject: [PATCH] [FIX] Do not FormView#do_show() twice on cold do_load_state() bzr revid: fme@openerp.com-20120201154442-gwbdm99wy8qahwie --- addons/web/static/src/js/chrome.js | 2 +- addons/web/static/src/js/view_form.js | 11 ++++++----- addons/web/static/src/js/view_list.js | 2 +- addons/web/static/src/js/views.js | 10 +++++----- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 58a340e3a59..ae40c1affe7 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -1162,7 +1162,7 @@ openerp.web.WebClient = openerp.web.OldWidget.extend(/** @lends openerp.web.WebC on_hashchange: function(event) { var state = event.getState(true); if (!_.isEqual(this._current_state, state)) { - this.action_manager.do_load_state(state); + this.action_manager.do_load_state(state, !!this._current_state); } this._current_state = state; }, diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index c82b7d908d7..4010bab1f94 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -121,14 +121,15 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView# this.has_been_loaded.resolve(); }, - do_load_state: function(state) { + do_load_state: function(state, warm) { if (state.id && this.datarecord.id != state.id) { - var idx = this.dataset.get_id_index(state.id); - if (idx === null) { + if (!this.dataset.get_id_index(state.id)) { this.dataset.ids.push(state.id); - this.dataset.index = this.dataset.ids.length - 1; } - this.do_show(); + this.dataset.select_id(state.id); + if (warm) { + this.do_show(); + } } }, diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 94933d5064a..f9d307e811b 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -475,7 +475,7 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# return this.reload_content(); }, - do_load_state: function(state) { + do_load_state: function(state, warm) { var reload = false; if (state.page && this.page !== state.page) { this.page = state.page; diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 5ec9262d621..7c1f7385927 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -57,7 +57,7 @@ session.web.ActionManager = session.web.OldWidget.extend({ this.widget_parent.do_push_state(state); } }, - do_load_state: function(state) { + do_load_state: function(state, warm) { var self = this, action_loaded; if (state.action_id) { @@ -92,7 +92,7 @@ session.web.ActionManager = session.web.OldWidget.extend({ $.when(action_loaded || null).then(function() { if (self.inner_viewmanager) { - self.inner_viewmanager.do_load_state(state); + self.inner_viewmanager.do_load_state(state, warm); } }); }, @@ -695,7 +695,7 @@ session.web.ViewManagerAction = session.web.ViewManager.extend(/** @lends oepner this.widget_parent.do_push_state(state); } }, - do_load_state: function(state) { + do_load_state: function(state, warm) { var self = this, defs = []; if (state.view_type && state.view_type !== this.active_view) { @@ -707,7 +707,7 @@ session.web.ViewManagerAction = session.web.ViewManager.extend(/** @lends oepner } $.when(defs).then(function() { - self.views[self.active_view].controller.do_load_state(state); + self.views[self.active_view].controller.do_load_state(state, warm); }); }, shortcut_check : function(view) { @@ -1181,7 +1181,7 @@ session.web.View = session.web.Widget.extend(/** @lends session.web.View# */{ this.widget_parent.do_push_state(state); } }, - do_load_state: function(state) { + do_load_state: function(state, warm) { }, /** * Switches to a specific view type