diff options
| author | Xavier Morel <xmo@openerp.com> | 2011-05-17 12:01:05 +0200 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2011-05-17 12:01:05 +0200 |
| commit | fdff3408ec5a4074009dd55f9110f85a93518e72 (patch) | |
| tree | 20b05de099cfbecfff0b13b0bbf10371b629d417 /addons/base | |
| parent | 8c6880a0d683193ad20e910bc722d8583926ef4c (diff) | |
| parent | a6568345163fbcbd6f0e563952b976c47cc087a8 (diff) | |
[MERGE] a few trunk improvements
bzr revid: xmo@openerp.com-20110517100105-6ad5urt4gwydlbl8
Diffstat (limited to 'addons/base')
| -rw-r--r-- | addons/base/static/src/js/base.js | 7 | ||||
| -rw-r--r-- | addons/base/static/src/js/form.js | 12 | ||||
| -rw-r--r-- | addons/base/static/src/js/views.js | 14 |
3 files changed, 23 insertions, 10 deletions
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); } }, |
