diff --git a/addons/base/static/src/js/base.js b/addons/base/static/src/js/base.js index 19d608e0260..7ee9c947d1e 100644 --- a/addons/base/static/src/js/base.js +++ b/addons/base/static/src/js/base.js @@ -44,8 +44,11 @@ // The dummy class constructor function Class() { // All construction is actually done in the init method - if ( !initializing && this.init ) - this.init.apply(this, arguments); + if ( !initializing && this.init ) { + var ret = this.init.apply(this, arguments); + if (ret) { return ret; } + } + return this; } // Populate our constructed prototype object diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index dc631c1256a..deed1c526d0 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -321,7 +321,7 @@ openerp.base.form.compute_domain = function(expr, fields) { var ex = expr[i]; if (ex.length == 1) { var top = stack.pop(); - switch (ex[0]) { + switch (ex) { case '|': stack.push(stack.pop() || top); continue; @@ -332,7 +332,7 @@ openerp.base.form.compute_domain = function(expr, fields) { stack.push(!top); continue; default: - throw new Error('Unknown domain operator ' + ex[0]); + throw new Error('Unknown domain operator ' + ex); } } @@ -362,17 +362,17 @@ openerp.base.form.compute_domain = function(expr, fields) { stack.push(field >= val); break; case 'in': - stack.push(_.indexOf(val, field) > -1); + stack.push(_(val).contains(field)); break; case 'not in': - stack.push(_.indexOf(val, field) == -1); + stack.push(!_(val).contains(field)); break; default: this.log("Unsupported operator in attrs :", op); } } - return _.indexOf(stack, false) == -1; -} + return _.all(stack); +}; openerp.base.form.Widget = openerp.base.Controller.extend({ init: function(view, node) { diff --git a/addons/base/static/src/js/views.js b/addons/base/static/src/js/views.js index dee28dfafa9..c7363fbb9c7 100644 --- a/addons/base/static/src/js/views.js +++ b/addons/base/static/src/js/views.js @@ -24,6 +24,7 @@ openerp.base.ActionManager = openerp.base.Controller.extend({ sidebar : true, search_view : true, new_window : false, + views_switcher : true, toolbar : true, pager : true }, action.flags || {}); @@ -46,6 +47,7 @@ openerp.base.ActionManager = openerp.base.Controller.extend({ viewmanager.start(); this.dialog_stack.push(viewmanager); } else if (action.flags.new_window) { + action.flags.new_window = false; this.rpc("/base/session/save_session_action", { the_action : action}, function(key) { var url = window.location.protocol + "//" + window.location.host + window.location.pathname + "?" + jQuery.param({ s_action : "" + key }); @@ -79,6 +81,7 @@ openerp.base.ViewManager = openerp.base.Controller.extend({ this.active_view = null; this.views_src = views; this.views = {}; + this.flags = this.flags || {}; }, /** * @returns {jQuery.Deferred} initial view loading promise @@ -93,6 +96,9 @@ openerp.base.ViewManager = openerp.base.Controller.extend({ _.each(this.views_src, function(view) { self.views[view[1]] = { view_id: view[0], controller: null }; }); + if (this.flags.views_switcher === false) { + this.$element.find('.oe_vm_switch').hide(); + } // switch to the first one in sequence return this.on_mode_switch(this.views_src[0][1]); }, @@ -116,7 +122,7 @@ openerp.base.ViewManager = openerp.base.Controller.extend({ this.views[view_type].controller = controller; } - if(this.searchview) { + if (this.searchview) { if (view.controller.searchable === false) { this.searchview.hide(); } else { @@ -152,6 +158,9 @@ openerp.base.ViewManager = openerp.base.Controller.extend({ this.searchview.stop(); } this.searchview = new openerp.base.SearchView(this, this.session, this.element_id + "_search", this.dataset, view_id, search_defaults); + if (this.flags.search_view === false) { + this.searchview.hide(); + } this.searchview.on_search.add(function(domains, contexts, groupbys) { self.views[self.active_view].controller.do_search.call( self, domains.concat(self.domains()), @@ -201,7 +210,8 @@ openerp.base.ViewManagerAction = openerp.base.ViewManager.extend({ } this._super(session, element_id, dataset, action.views); this.action = action; - if (action.flags.sidebar) { + this.flags = this.action.flags || {}; + if (this.flags.sidebar) { this.sidebar = new openerp.base.Sidebar(null, this); } }, diff --git a/addons/base_dashboard/static/src/js/dashboard.js b/addons/base_dashboard/static/src/js/dashboard.js index 34d09f80e62..1d8f433bd40 100644 --- a/addons/base_dashboard/static/src/js/dashboard.js +++ b/addons/base_dashboard/static/src/js/dashboard.js @@ -55,10 +55,11 @@ openerp.base.form.Action = openerp.base.form.Widget.extend({ on_load_action: function(result) { var action = result.action; - action.search_view = false; - action.no_sidebar = true; - action.search_view_id = false; - + action.flags = { + search_view : false, + sidebar : false, + views_switcher : false + } var node_attrs = this.node.attrs; var get_column = ['first', 'second', 'third']; var board_element = this.board.element.find('[id=column-'+get_column[this.child_index]+']'); @@ -101,4 +102,4 @@ openerp.base.form.Vpaned = openerp.base.form.Widget.extend({ openerp.base.form.widgets.add('hpaned', 'openerp.base.form.Board'); openerp.base.form.widgets.add('vpaned', 'openerp.base.form.Vpaned'); openerp.base.form.widgets.add('action', 'openerp.base.form.Action'); -} \ No newline at end of file +}