[FIX] Fix one custom filter bug (only scratch the surface of this problem)
bzr revid: fme@openerp.com-20130114093014-5sv1sfk5u2uemwlr
This commit is contained in:
parent
3ed5d3ab08
commit
8c1f9dc490
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue