[FIX] Do not FormView#do_show() twice on cold do_load_state()

bzr revid: fme@openerp.com-20120201154442-gwbdm99wy8qahwie
This commit is contained in:
Fabien Meghazi 2012-02-01 16:44:42 +01:00
parent e7ccb31154
commit 5e7b30e996
4 changed files with 13 additions and 12 deletions

View File

@ -1162,7 +1162,7 @@ openerp.web.WebClient = openerp.web.OldWidget.extend(/** @lends openerp.web.WebC
on_hashchange: function(event) { on_hashchange: function(event) {
var state = event.getState(true); var state = event.getState(true);
if (!_.isEqual(this._current_state, state)) { 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; this._current_state = state;
}, },

View File

@ -121,14 +121,15 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
this.has_been_loaded.resolve(); this.has_been_loaded.resolve();
}, },
do_load_state: function(state) { do_load_state: function(state, warm) {
if (state.id && this.datarecord.id != state.id) { if (state.id && this.datarecord.id != state.id) {
var idx = this.dataset.get_id_index(state.id); if (!this.dataset.get_id_index(state.id)) {
if (idx === null) {
this.dataset.ids.push(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();
}
} }
}, },

View File

@ -475,7 +475,7 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
return this.reload_content(); return this.reload_content();
}, },
do_load_state: function(state) { do_load_state: function(state, warm) {
var reload = false; var reload = false;
if (state.page && this.page !== state.page) { if (state.page && this.page !== state.page) {
this.page = state.page; this.page = state.page;

View File

@ -57,7 +57,7 @@ session.web.ActionManager = session.web.OldWidget.extend({
this.widget_parent.do_push_state(state); this.widget_parent.do_push_state(state);
} }
}, },
do_load_state: function(state) { do_load_state: function(state, warm) {
var self = this, var self = this,
action_loaded; action_loaded;
if (state.action_id) { if (state.action_id) {
@ -92,7 +92,7 @@ session.web.ActionManager = session.web.OldWidget.extend({
$.when(action_loaded || null).then(function() { $.when(action_loaded || null).then(function() {
if (self.inner_viewmanager) { 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); this.widget_parent.do_push_state(state);
} }
}, },
do_load_state: function(state) { do_load_state: function(state, warm) {
var self = this, var self = this,
defs = []; defs = [];
if (state.view_type && state.view_type !== this.active_view) { 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() { $.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) { 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); this.widget_parent.do_push_state(state);
} }
}, },
do_load_state: function(state) { do_load_state: function(state, warm) {
}, },
/** /**
* Switches to a specific view type * Switches to a specific view type