[FIX] url handling of record id

bzr revid: chs@openerp.com-20111215142939-j2lz1irzoj10fy3v
This commit is contained in:
Christophe Simonis 2011-12-15 15:29:39 +01:00
parent 2d1baf3dda
commit af2e4fe2b5
2 changed files with 34 additions and 10 deletions

View File

@ -117,6 +117,18 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
}
this.has_been_loaded.resolve();
},
do_load_state: function(state) {
if (state.id && this.datarecord.id != state.id) {
var idx = this.dataset.get_id_index(state.id);
if (idx === null) {
this.dataset.ids.push(state.id)
this.dataset.index = this.dataset.ids.length - 1;
}
this.do_show();
}
},
do_show: function () {
var promise;
if (this.dataset.index === null) {

View File

@ -56,31 +56,38 @@ session.web.ActionManager = session.web.Widget.extend({
}
},
do_load_state: function(state) {
var self = this,
action_loaded;
if (state.action_id) {
this.null_action();
this.do_action(state.action_id);
var run_action = (!this.inner_viewmanager) || this.inner_viewmanager.action.id !== state.action_id;
if (run_action) {
this.null_action();
action_loaded = this.do_action(state.action_id);
}
}
else if (state.model && state.id) {
// TODO implement it
//this.null_action();
// action = {}
//action = {res_model: state.model, res_id: state.id};
//action_loaded = this.do_action(action);
}
else if (state.client_action) {
this.null_action();
this.ir_actions_client(state.client_action);
}
if (this.inner_viewmanager) {
this.inner_viewmanager.do_load_state(state);
}
$.when(action_loaded || null).then(function() {
if (self.inner_viewmanager) {
self.inner_viewmanager.do_load_state(state);
}
});
},
do_action: function(action, on_close) {
if (_.isNumber(action)) {
var self = this;
self.rpc("/web/action/load", { action_id: action }, function(result) {
return self.rpc("/web/action/load", { action_id: action }, function(result) {
self.do_action(result.result, on_close);
});
return;
}
if (!action.type) {
console.error("No type for action", action);
@ -583,8 +590,13 @@ session.web.ViewManagerAction = session.web.ViewManager.extend(/** @lends oepner
}
},
do_load_state: function(state) {
var self = this;
$.when(this.on_mode_switch(state.view_type, true)).done(function() {
var self = this,
defs = [];
if (state.view_type && state.view_type !== this.active_view) {
defs.push(this.on_mode_switch(state.view_type, true));
}
$.when(defs).then(function() {
self.views[self.active_view].controller.do_load_state(state);
});
},