[IMP] allow xml ids for action_id
bzr revid: al@openerp.com-20120713145740-xkwp0hxy7kou61f0
This commit is contained in:
parent
1176476743
commit
71a5c53072
|
@ -1494,10 +1494,6 @@ class Binary(openerpweb.Controller):
|
|||
|
||||
class Action(openerpweb.Controller):
|
||||
_cp_path = "/web/action"
|
||||
|
||||
action_mapping = {
|
||||
"ir.actions.act_url": "ir.actions.url",
|
||||
}
|
||||
|
||||
# For most actions, the type attribute and the model name are the same, but
|
||||
# there are exceptions. This dict is used to remap action type attributes
|
||||
|
@ -1511,6 +1507,17 @@ class Action(openerpweb.Controller):
|
|||
Actions = req.session.model('ir.actions.actions')
|
||||
value = False
|
||||
context = req.session.eval_context(req.context)
|
||||
|
||||
try:
|
||||
action_id = int(action_id)
|
||||
except ValueError:
|
||||
try:
|
||||
module, xmlid = action_id.split('.', 1)
|
||||
model, action_id = req.session.model('ir.model.data').get_object_reference(module, xmlid)
|
||||
assert model.startswith('ir.actions.')
|
||||
except Exception:
|
||||
action_id = 0 # force failed read
|
||||
|
||||
base_action = Actions.read([action_id], ['type'], context)
|
||||
if base_action:
|
||||
ctx = {}
|
||||
|
|
|
@ -667,7 +667,7 @@ instance.web.Menu = instance.web.Widget.extend({
|
|||
* @param {Number} id the action_id to match
|
||||
*/
|
||||
open_action: function (id) {
|
||||
var $menu = this.$element.add(this.$secondary_menus).find('a[data-action-id=' + id + ']');
|
||||
var $menu = this.$element.add(this.$secondary_menus).find('a[data-action-id="' + id + '"]');
|
||||
var menu_id = $menu.data('menu');
|
||||
if (menu_id) {
|
||||
this.open_menu(menu_id);
|
||||
|
|
|
@ -178,7 +178,7 @@ instance.web.ActionManager = instance.web.Widget.extend({
|
|||
});
|
||||
},
|
||||
do_action: function(action, on_close) {
|
||||
if (_.isNumber(action)) {
|
||||
if (_.isNumber(action) || _.isString(action)) {
|
||||
var self = this;
|
||||
return self.rpc("/web/action/load", { action_id: action }, function(result) {
|
||||
self.do_action(result.result, on_close);
|
||||
|
@ -1261,7 +1261,7 @@ instance.web.View = instance.web.Widget.extend({
|
|||
args.push(context);
|
||||
return dataset.call_button(action_data.name, args, handler);
|
||||
} else if (action_data.type=="action") {
|
||||
return this.rpc('/web/action/load', { action_id: parseInt(action_data.name, 10), context: context, do_not_eval: true}, handler);
|
||||
return this.rpc('/web/action/load', { action_id: action_data.name, context: context, do_not_eval: true}, handler);
|
||||
} else {
|
||||
return dataset.exec_workflow(record_id, action_data.name, handler);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue