summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorFabien Meghazi <fme@openerp.com>2013-01-14 10:30:14 +0100
committerFabien Meghazi <fme@openerp.com>2013-01-14 10:30:14 +0100
commit8c1f9dc490756bb5e72f74d62c5bee85fddee9b4 (patch)
treed9cc1865a02d2454d479f12879f95567720db091 /addons/web/static/src
parent3ed5d3ab082e0ff45ce26b44fbce44fb7d83a5a4 (diff)
[FIX] Fix one custom filter bug (only scratch the surface of this problem)
bzr revid: fme@openerp.com-20130114093014-5sv1sfk5u2uemwlr
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/search.js17
-rw-r--r--addons/web/static/src/js/views.js20
2 files changed, 26 insertions, 11 deletions
diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js
index 34ab101fea7..50e768bac59 100644
--- a/addons/web/static/src/js/search.js
+++ b/addons/web/static/src/js/search.js
@@ -305,9 +305,15 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
* @param dataset
* @param view_id
* @param defaults
- * @param hidden
+ * @param {Object} [options]
+ * @param {Boolean} [options.hidden=false] hide the search view
+ * @param {Boolean} [options.disable_custom_filters=false] do not load custom filters from ir.filters
*/
- init: function(parent, dataset, view_id, defaults, hidden) {
+ init: function(parent, dataset, view_id, defaults, options) {
+ this.options = _.defaults(options || {}, {
+ hidden: false,
+ disable_custom_filters: false,
+ });
this._super(parent);
this.dataset = dataset;
this.model = dataset.model;
@@ -319,8 +325,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
this.inputs = [];
this.controls = {};
- this.hidden = !!hidden;
- this.headless = this.hidden && !this.has_defaults;
+ this.headless = this.options.hidden && !this.has_defaults;
this.input_subviews = [];
@@ -335,7 +340,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
.on('add change reset remove', this.proxy('do_search'))
.on('add change reset remove', this.proxy('renderFacets'));
- if (this.hidden) {
+ if (this.options.hidden) {
this.$el.hide();
}
if (this.headless) {
@@ -650,7 +655,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
// CustomFilters will be ready (and CustomFilters#filters will be
// correctly filled) by the time this method executes.
var custom_filters = this.custom_filters.filters;
- if (!_(custom_filters).isEmpty()) {
+ if (!this.options.disable_custom_filters && !_(custom_filters).isEmpty()) {
// Check for any is_default custom filter
var personal_filter = _(custom_filters).find(function (filter) {
return filter.user_id && filter.is_default;
diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js
index 4a7c1aff69c..9fd49367171 100644
--- a/addons/web/static/src/js/views.js
+++ b/addons/web/static/src/js/views.js
@@ -285,14 +285,15 @@ instance.web.ActionManager = instance.web.Widget.extend({
var type = action.type.replace(/\./g,'_');
var popup = action.target === 'new';
var inline = action.target === 'inline' || action.target === 'inlineview';
- action.flags = _.extend({
+ action.flags = _.defaults(action.flags || {}, {
views_switcher : !popup && !inline,
search_view : !popup && !inline,
action_buttons : !popup && !inline,
sidebar : !popup && !inline,
pager : !popup && !inline,
- display_title : !popup
- }, action.flags || {});
+ display_title : !popup,
+ search_disable_custom_filters: action.context && action.context.search_disable_custom_filters
+ });
action.menu_id = options.action_menu_id;
if (!(type in this)) {
console.error("Action manager can't handle action of type " + action.type, action);
@@ -526,7 +527,7 @@ instance.web.ViewManager = instance.web.Widget.extend({
}
if (this.searchview) {
- this.searchview[(view.controller.searchable === false || this.searchview.hidden) ? 'hide' : 'show']();
+ this.searchview[(view.controller.searchable === false || this.searchview.options.hidden) ? 'hide' : 'show']();
}
this.$el.find('.oe_view_manager_switch a').parent().removeClass('active');
@@ -684,7 +685,11 @@ instance.web.ViewManager = instance.web.Widget.extend({
if (this.searchview) {
this.searchview.destroy();
}
- this.searchview = new instance.web.SearchView(this, this.dataset, view_id, search_defaults, this.flags.search_view === false);
+ var options = {
+ hidden: this.flags.search_view === false,
+ disable_custom_filters: this.flags.search_disable_custom_filters,
+ };
+ this.searchview = new instance.web.SearchView(this, this.dataset, view_id, search_defaults, options);
this.searchview.on('search_data', self, this.do_searchview_search);
return this.searchview.appendTo(this.$el.find(".oe_view_manager_view_search"));
@@ -1265,6 +1270,11 @@ instance.web.View = instance.web.Widget.extend({
active_ids: [record_id],
active_model: dataset.model
});
+ if (("" + action.context).match(/\bactive_id\b/)) {
+ // Special case: when the context is evaluted using
+ // the active_id, we want to disable the custom filters.
+ ncontext.add({ search_disable_custom_filters: true });
+ }
}
ncontext.add(action.context || {});
action.context = ncontext;