@@ -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 = {}
|
||||
|
||||
@@ -86,7 +86,7 @@ instance.web.Dialog = instance.web.Widget.extend({
|
||||
if (this.dialog_options.autoOpen) {
|
||||
this.open();
|
||||
} else {
|
||||
test = instance.web.dialog(this.$element, this.get_options());
|
||||
instance.web.dialog(this.$element, this.get_options());
|
||||
}
|
||||
},
|
||||
get_options: function(options) {
|
||||
@@ -145,9 +145,9 @@ instance.web.Dialog = instance.web.Widget.extend({
|
||||
_.each(this.getChildren(), function(el) {
|
||||
el.destroy();
|
||||
});
|
||||
if (! this.isDestroyed()) {
|
||||
this.$element.dialog('destroy');
|
||||
}
|
||||
if (! this.isDestroyed()) {
|
||||
this.$element.dialog('destroy');
|
||||
}
|
||||
this._super();
|
||||
}
|
||||
});
|
||||
@@ -212,11 +212,11 @@ instance.web.CrashManager = instance.web.CallbackEnabled.extend({
|
||||
dialog.$element.html(QWeb.render('CrashManager.error', {session: instance.connection, error: error}));
|
||||
},
|
||||
on_javascript_exception: function(exception) {
|
||||
this.on_traceback({
|
||||
type: _t("Client Error"),
|
||||
message: exception,
|
||||
data: {debug: ""}
|
||||
});
|
||||
this.on_traceback({
|
||||
type: _t("Client Error"),
|
||||
message: exception,
|
||||
data: {debug: ""}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -482,24 +482,26 @@ instance.web.Login = instance.web.Widget.extend({
|
||||
}
|
||||
}
|
||||
},
|
||||
open_db_manager: function(){
|
||||
var self = this;
|
||||
self.$element.find('.oe_login_bottom').hide();
|
||||
self.$element.find('.oe_login_pane').hide();
|
||||
self.databasemanager = new instance.web.DatabaseManager(self);
|
||||
self.databasemanager.appendTo(self.$element);
|
||||
self.databasemanager.do_exit.add_last(function() {
|
||||
self.databasemanager.destroy();
|
||||
self.$element.find('.oe_login_bottom').show();
|
||||
self.$element.find('.oe_login_pane').show();
|
||||
self.load_db_list(true).then(self.on_db_list_loaded);
|
||||
});
|
||||
},
|
||||
start: function() {
|
||||
var self = this;
|
||||
|
||||
self.$element.find("form").submit(self.on_submit);
|
||||
|
||||
self.$element.find('.oe_login_manage_db').click(function() {
|
||||
self.$element.find('.oe_login_bottom').hide();
|
||||
self.$element.find('.oe_login_pane').hide();
|
||||
self.databasemanager = new instance.web.DatabaseManager(self);
|
||||
self.databasemanager.appendTo(self.$element);
|
||||
self.databasemanager.do_exit.add_last(function() {
|
||||
self.databasemanager.destroy();
|
||||
self.$element.find('.oe_login_bottom').show();
|
||||
self.$element.find('.oe_login_pane').show();
|
||||
self.load_db_list(true).then(self.proxy('_db_list_loaded'));
|
||||
});
|
||||
self.open_db_manager();
|
||||
});
|
||||
return self.load_db_list().then(self.proxy('_db_list_loaded'));
|
||||
return self.load_db_list().then(self.on_db_list_loaded);
|
||||
},
|
||||
load_db_list: function (force) {
|
||||
var d = $.when(), self = this;
|
||||
@@ -514,11 +516,14 @@ instance.web.Login = instance.web.Widget.extend({
|
||||
}
|
||||
return d;
|
||||
},
|
||||
_db_list_loaded: function () {
|
||||
var list = this._db_list,
|
||||
dbdiv = this.$element.find('div.oe_login_dbpane');
|
||||
on_db_list_loaded: function () {
|
||||
var self = this;
|
||||
var list = this._db_list;
|
||||
var dbdiv = this.$element.find('div.oe_login_dbpane');
|
||||
this.$element.find("[name=db]").replaceWith(instance.web.qweb.render('Login.dblist', { db_list: list, selected_db: this.selected_db}));
|
||||
if(list && list.length === 1) {
|
||||
if(list.length === 0) {
|
||||
self.open_db_manager();
|
||||
} else if(list && list.length === 1) {
|
||||
dbdiv.hide();
|
||||
} else {
|
||||
dbdiv.show();
|
||||
@@ -667,7 +672,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);
|
||||
|
||||
@@ -404,10 +404,11 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Event Bus used to bind events scoped in the current instance
|
||||
*/
|
||||
instance.web.bus = new (instance.web.Class.extend(instance.web.EventDispatcherMixin, {
|
||||
instance.web.Bus = instance.web.Class.extend(instance.web.EventDispatcherMixin, {
|
||||
init: function() {
|
||||
instance.web.EventDispatcherMixin.init.call(this, parent);
|
||||
var self = this;
|
||||
@@ -425,7 +426,8 @@ instance.web.bus = new (instance.web.Class.extend(instance.web.EventDispatcherMi
|
||||
});
|
||||
});
|
||||
}
|
||||
}))();
|
||||
})
|
||||
instance.web.bus = new instance.web.Bus();
|
||||
|
||||
/** OpenERP Translations */
|
||||
instance.web.TranslationDataBase = instance.web.Class.extend(/** @lends instance.web.TranslationDataBase# */{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user