[ADD] Added support for buttons of type 'workflow'
bzr revid: fme@openerp.com-20110421161343-k0jejshvx12nf9ex
This commit is contained in:
parent
3e4c62c536
commit
14270adaaf
|
@ -634,4 +634,4 @@ class Action(openerpweb.Controller):
|
|||
action = req.session.model(action_type[0]['type']).read([action_id], False, context)
|
||||
if action:
|
||||
value = action[0]
|
||||
return {'value': value}
|
||||
return {'result': value}
|
||||
|
|
|
@ -532,7 +532,7 @@ openerp.base.form.WidgetButton = openerp.base.form.Widget.extend({
|
|||
on_confirmed: function() {
|
||||
var attrs = this.node.attrs;
|
||||
if (attrs.special) {
|
||||
this.on_button_object({
|
||||
this.on_button_action({
|
||||
result : { type: 'ir.actions.act_window_close' }
|
||||
});
|
||||
} else {
|
||||
|
@ -540,20 +540,20 @@ openerp.base.form.WidgetButton = openerp.base.form.Widget.extend({
|
|||
var context = _.extend({}, this.view.dataset.context, attrs.context || {});
|
||||
switch(type) {
|
||||
case 'object':
|
||||
return this.view.dataset.call(attrs.name, [this.view.datarecord.id], [context], this.on_button_object);
|
||||
return this.view.dataset.call(attrs.name, [this.view.datarecord.id], [context], this.on_button_action);
|
||||
case 'action':
|
||||
return this.session.action_manager.do_action_id(parseInt(this.node.attrs.name));
|
||||
return this.rpc('/base/action/load', { action_id: parseInt(attrs.name) }, this.on_button_action);
|
||||
default:
|
||||
this.log(_.sprintf("Unsupported button type : %s", type), this.node);
|
||||
return this.view.dataset.exec_workflow(this.view.datarecord.id, attrs.name, this.on_button_action);
|
||||
}
|
||||
}
|
||||
},
|
||||
on_button_object: function(r) {
|
||||
if (r.result === false) {
|
||||
this.log("Button object returns false");
|
||||
} else if (r.result.constructor == Object) {
|
||||
on_button_action: function(r) {
|
||||
console.log("Got reesonse button", r)
|
||||
if (r.result && r.result.constructor == Object) {
|
||||
this.session.action_manager.do_action(r.result);
|
||||
} else {
|
||||
this.log("Button returned", r.result);
|
||||
this.view.reload();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,16 +18,6 @@ openerp.base.ActionManager = openerp.base.Controller.extend({
|
|||
* Process an action
|
||||
* Supported actions: act_window
|
||||
*/
|
||||
do_action_id: function(action_id) {
|
||||
var self = this;
|
||||
this.rpc('/base/action/load', { action_id: action_id }, function(result) {
|
||||
if (result instanceof Object) {
|
||||
self.do_action(result.value);
|
||||
} else {
|
||||
this.log("Could not load action with id ", action_id);
|
||||
}
|
||||
});
|
||||
},
|
||||
do_action: function(action) {
|
||||
var self = this;
|
||||
// instantiate the right controllers by understanding the action
|
||||
|
@ -193,7 +183,6 @@ openerp.base.ViewManager = openerp.base.Controller.extend({
|
|||
|
||||
openerp.base.ViewManagerAction = openerp.base.ViewManager.extend({
|
||||
init: function(session, element_id, action, sidebar) {
|
||||
console.log("init view manager action", action)
|
||||
var dataset = new openerp.base.DataSetSearch(session, action.res_model);
|
||||
this._super(session, element_id, dataset, action.views);
|
||||
this.action = action;
|
||||
|
|
Loading…
Reference in New Issue