diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index 3d66c4f4ccf..12422fb5434 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -254,14 +254,16 @@ openerp.web.Registry = openerp.web.Class.extend( /** @lends openerp.web.Registry * Retrieves the object matching the provided key string. * * @param {String} key the key to fetch the object for + * @param {Boolean} [silent_error=false] returns undefined if the key or object is not found, rather than throwing an exception * @returns {Class} the stored class, to initialize * * @throws {openerp.web.KeyNotFound} if the object was not in the mapping * @throws {openerp.web.ObjectNotFound} if the object path was invalid */ - get_object: function (key) { + get_object: function (key, silent_error) { var path_string = this.map[key]; if (path_string === undefined) { + if (silent_error) { return void 'nooo'; } throw new openerp.web.KeyNotFound(key); } @@ -272,6 +274,7 @@ openerp.web.Registry = openerp.web.Class.extend( /** @lends openerp.web.Registry object_match = object_match[path[i]]; if (object_match === undefined) { + if (silent_error) { return void 'noooooo'; } throw new openerp.web.ObjectNotFound(path_string); } } diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 2e00e343b50..0d962353b78 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -13,6 +13,7 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView# readonly : false, form_template: "FormView", identifier_prefix: 'formview-', + display_name: {toString: function () { return _t('Form'); }}, /** * @constructs openerp.web.FormView * @extends openerp.web.View diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 86749849053..8ed475c75f6 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -4,6 +4,7 @@ var QWeb = openerp.web.qweb; openerp.web.views.add('list', 'openerp.web.ListView'); openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# */ { _template: 'ListView', + display_name: {toString: function () { return _t('List'); }}, defaults: { // records can be selected one by one 'selectable': true, diff --git a/addons/web/static/src/js/view_page.js b/addons/web/static/src/js/view_page.js index 060c95e86e3..1b23198da67 100644 --- a/addons/web/static/src/js/view_page.js +++ b/addons/web/static/src/js/view_page.js @@ -5,6 +5,7 @@ openerp.web.page = function (openerp) { openerp.web.views.add('page', 'openerp.web.PageView'); openerp.web.PageView = openerp.web.FormView.extend({ form_template: "PageView", + display_name: {toString: function () { return _t('Page'); }}, init: function () { this._super.apply(this, arguments); this.registry = openerp.web.page.readonly; diff --git a/addons/web/static/src/js/view_tree.js b/addons/web/static/src/js/view_tree.js index 869e23fc16d..48f7290c8d9 100644 --- a/addons/web/static/src/js/view_tree.js +++ b/addons/web/static/src/js/view_tree.js @@ -3,10 +3,12 @@ *---------------------------------------------------------*/ openerp.web.view_tree = function(openerp) { -var QWeb = openerp.web.qweb; +var QWeb = openerp.web.qweb, + _t = openerp.web._t; openerp.web.views.add('tree', 'openerp.web.TreeView'); openerp.web.TreeView = openerp.web.View.extend(/** @lends openerp.web.TreeView# */{ + display_name: {toString: function () { return _t('Tree'); }}, /** * Indicates that this view is not searchable, and thus that no search * view should be displayed (if there is one active). diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 579027a360a..5800939ec36 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -210,7 +210,18 @@ session.web.ViewManager = session.web.Widget.extend(/** @lends session.web.View this.dataset = dataset; this.searchview = null; this.active_view = null; - this.views_src = _.map(views, function(x) {return x instanceof Array? {view_id: x[0], view_type: x[1]} : x;}); + this.views_src = _.map(views, function(x) { + if (x instanceof Array) { + var View = session.web.views.get_object(x[1], true); + return { + view_id: x[0], + view_type: x[1], + label: View ? View.prototype.display_name : (void 'nope') + }; + } else { + return x; + } + }); this.views = {}; this.flags = flags || {}; this.registry = session.web.views; @@ -967,6 +978,8 @@ session.web.TranslateDialog = session.web.Dialog.extend({ session.web.View = session.web.Widget.extend(/** @lends session.web.View# */{ template: "EmptyComponent", + // name displayed in view switchers + display_name: '', set_default_options: function(options) { this.options = options || {}; _.defaults(this.options, { diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index ff21856aeff..c7b32cef6d7 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -424,7 +424,7 @@