[FIX] Fixed active_is in context for dialog actions

bzr revid: fme@openerp.com-20110621143804-b51tp8n0a393oixi
This commit is contained in:
Fabien Meghazi 2011-06-21 16:38:04 +02:00
parent 74e3e05763
commit c57a3e0d98
3 changed files with 23 additions and 10 deletions

View File

@ -287,11 +287,12 @@ openerp.base.DataSet = openerp.base.Controller.extend( /** @lends openerp.base.
});
}
},
default_get: function(fields, callback) {
default_get: function(fields, context, callback) {
context = context || this.context;
return this.rpc('/base/dataset/default_get', {
model: this.model,
fields: fields,
context: this.context
context: context
}, callback);
},
create: function(data, callback, error_callback) {

View File

@ -42,8 +42,12 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormV
if (this.embedded_view) {
return $.Deferred().then(this.on_loaded).resolve({fields_view: this.embedded_view});
} else {
var context = new openerp.base.CompoundContext(this.dataset.context);
if (this.view_manager.action && this.view_manager.action.context) {
context.add(this.view_manager.action.context);
}
return this.rpc("/base/formview/load", {"model": this.model, "view_id": this.view_id,
toolbar:!!this.flags.sidebar}, this.on_loaded);
toolbar:!!this.flags.sidebar, context: context}, this.on_loaded);
}
},
on_loaded: function(data) {
@ -84,7 +88,6 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormV
this.$element.hide();
},
on_record_loaded: function(record) {
console.info(record)
this.touched = false;
if (record) {
this.datarecord = record;
@ -226,8 +229,12 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormV
},
on_button_new: function() {
var self = this;
var context = new openerp.base.CompoundContext(this.dataset.context);
if (this.view_manager.action && this.view_manager.action.context) {
context.add(this.view_manager.action.context);
}
$.when(this.has_been_loaded).then(function() {
self.dataset.default_get(_.keys(self.fields_view.fields), function(result) {
self.dataset.default_get(_.keys(self.fields_view.fields), context, function(result) {
self.on_record_loaded(result.result);
});
});

View File

@ -397,17 +397,22 @@ openerp.base.View = openerp.base.Controller.extend({
*/
execute_action: function (action_data, dataset, action_manager, record_id, on_no_action) {
var handler = function (r) {
if (r.result && r.result.constructor == Object) {
r.result.flags = {
var action = r.result;
if (action && action.constructor == Object) {
action.context = action.context || {};
action.context['active_id'] = dataset.ids[dataset.index];
action.context['active_ids'] = [dataset.ids[dataset.index]];
action.context['active_model'] = dataset.model;
action.flags = {
sidebar : false,
search_view : false,
views_switcher : false,
action_buttons : false,
pager : false
};
action_manager.do_action(r.result);
action_manager.do_action(action);
} else {
on_no_action(r.result);
on_no_action(action);
}
};
@ -421,7 +426,7 @@ openerp.base.View = openerp.base.Controller.extend({
case 'object':
return dataset.call_and_eval(action_data.name, [[record_id], context], null, 1, handler);
case 'action':
return this.rpc('/base/action/load', { action_id: parseInt(action_data.name, 10) }, handler);
return this.rpc('/base/action/load', { action_id: parseInt(action_data.name, 10), context: context }, handler);
default:
return dataset.exec_workflow(record_id, action_data.name, handler);
}