[ADD] Added support for buttons@type=action
bzr revid: fme@openerp.com-20110421132845-n2r6fa05q0qhvxjp
This commit is contained in:
parent
85c28f6d23
commit
190d61fbb9
|
@ -541,9 +541,10 @@ openerp.base.form.WidgetButton = openerp.base.form.Widget.extend({
|
|||
switch(type) {
|
||||
case 'object':
|
||||
return this.view.dataset.call(attrs.name, [this.view.datarecord.id], [context], this.on_button_object);
|
||||
break;
|
||||
case 'action':
|
||||
return this.session.action_manager.do_action_id(parseInt(this.node.attrs.name));
|
||||
default:
|
||||
this.log(_.sprintf("Unsupported button type : %s", type));
|
||||
this.log(_.sprintf("Unsupported button type : %s", type), this.node);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -18,8 +18,17 @@ 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) {
|
||||
this.log(action);
|
||||
var self = this;
|
||||
// instantiate the right controllers by understanding the action
|
||||
switch (action.type) {
|
||||
|
@ -36,14 +45,14 @@ openerp.base.ActionManager = openerp.base.Controller.extend({
|
|||
// When dialog is closed with ESC key or close manually, branch to act_window_close logic
|
||||
self.do_action({ type: 'ir.actions.act_window_close' });
|
||||
});
|
||||
var viewmanager = new openerp.base.ViewManagerAction(this.session ,element_id, action, false);
|
||||
var viewmanager = new openerp.base.ViewManagerAction(this.session, element_id, action, false);
|
||||
viewmanager.start();
|
||||
this.dialog_stack.push(viewmanager);
|
||||
} else if (action.target == "current") {
|
||||
} else {
|
||||
if (this.viewmanager) {
|
||||
this.viewmanager.stop();
|
||||
}
|
||||
this.viewmanager = new openerp.base.ViewManagerAction(this.session,this.element_id, action, true);
|
||||
this.viewmanager = new openerp.base.ViewManagerAction(this.session, this.element_id, action, true);
|
||||
this.viewmanager.start();
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue