[FIX] Fixed active_is in context for dialog actions
bzr revid: fme@openerp.com-20110621143804-b51tp8n0a393oixi
This commit is contained in:
parent
74e3e05763
commit
c57a3e0d98
|
@ -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', {
|
return this.rpc('/base/dataset/default_get', {
|
||||||
model: this.model,
|
model: this.model,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
context: this.context
|
context: context
|
||||||
}, callback);
|
}, callback);
|
||||||
},
|
},
|
||||||
create: function(data, callback, error_callback) {
|
create: function(data, callback, error_callback) {
|
||||||
|
|
|
@ -42,8 +42,12 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormV
|
||||||
if (this.embedded_view) {
|
if (this.embedded_view) {
|
||||||
return $.Deferred().then(this.on_loaded).resolve({fields_view: this.embedded_view});
|
return $.Deferred().then(this.on_loaded).resolve({fields_view: this.embedded_view});
|
||||||
} else {
|
} 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,
|
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) {
|
on_loaded: function(data) {
|
||||||
|
@ -84,7 +88,6 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormV
|
||||||
this.$element.hide();
|
this.$element.hide();
|
||||||
},
|
},
|
||||||
on_record_loaded: function(record) {
|
on_record_loaded: function(record) {
|
||||||
console.info(record)
|
|
||||||
this.touched = false;
|
this.touched = false;
|
||||||
if (record) {
|
if (record) {
|
||||||
this.datarecord = record;
|
this.datarecord = record;
|
||||||
|
@ -226,8 +229,12 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormV
|
||||||
},
|
},
|
||||||
on_button_new: function() {
|
on_button_new: function() {
|
||||||
var self = this;
|
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() {
|
$.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);
|
self.on_record_loaded(result.result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -397,17 +397,22 @@ openerp.base.View = openerp.base.Controller.extend({
|
||||||
*/
|
*/
|
||||||
execute_action: function (action_data, dataset, action_manager, record_id, on_no_action) {
|
execute_action: function (action_data, dataset, action_manager, record_id, on_no_action) {
|
||||||
var handler = function (r) {
|
var handler = function (r) {
|
||||||
if (r.result && r.result.constructor == Object) {
|
var action = r.result;
|
||||||
r.result.flags = {
|
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,
|
sidebar : false,
|
||||||
search_view : false,
|
search_view : false,
|
||||||
views_switcher : false,
|
views_switcher : false,
|
||||||
action_buttons : false,
|
action_buttons : false,
|
||||||
pager : false
|
pager : false
|
||||||
};
|
};
|
||||||
action_manager.do_action(r.result);
|
action_manager.do_action(action);
|
||||||
} else {
|
} else {
|
||||||
on_no_action(r.result);
|
on_no_action(action);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -421,7 +426,7 @@ openerp.base.View = openerp.base.Controller.extend({
|
||||||
case 'object':
|
case 'object':
|
||||||
return dataset.call_and_eval(action_data.name, [[record_id], context], null, 1, handler);
|
return dataset.call_and_eval(action_data.name, [[record_id], context], null, 1, handler);
|
||||||
case 'action':
|
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:
|
default:
|
||||||
return dataset.exec_workflow(record_id, action_data.name, handler);
|
return dataset.exec_workflow(record_id, action_data.name, handler);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue