[FIX] update tests and change search logic (webclient)

previous commit broke some tests.  The issue is that the search view
now avoid making requests if there is no action id.  But this is an
assumption that tests use, so some slight adjustments have to be made.

Also, this is the moment to give properly the action id to the favorite
menu.  Instead of bypassing its parent, it now receives the action id
from the search view.
This commit is contained in:
Géry Debongnie
2014-11-20 14:58:10 +01:00
parent 5cd78b891b
commit 77413fc764
3 changed files with 9 additions and 8 deletions
+5 -5
View File
@@ -387,7 +387,8 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
this.filter_menu = undefined;
this.groupby_menu = undefined;
this.favorite_menu = undefined
this.favorite_menu = undefined;
this.action_id = this.options && this.options.action && this.options.action.id;
},
start: function() {
if (this.headless) {
@@ -423,7 +424,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
this.groupby_menu = new my.GroupByMenu(this, this.groupbys, fields_def);
this.filter_menu = new my.FilterMenu(this, this.filters, fields_def);
this.favorite_menu = new my.FavoriteMenu(this, this.query, this.dataset.model);
this.favorite_menu = new my.FavoriteMenu(this, this.query, this.dataset.model, this.action_id);
this.filter_menu.appendTo(this.$buttons);
this.groupby_menu.appendTo(this.$buttons);
@@ -1581,7 +1582,7 @@ instance.web.search.FavoriteMenu = instance.web.Widget.extend({
this.close_menus();
},
},
init: function (parent, query, target_model) {
init: function (parent, query, target_model, action_id) {
this._super.apply(this,arguments);
this.searchview = parent;
this.query = query;
@@ -1589,8 +1590,7 @@ instance.web.search.FavoriteMenu = instance.web.Widget.extend({
this.model = new instance.web.Model('ir.filters');
this.filters = {};
this.$filters = {};
var action = instance.client.action_manager.inner_action;
this.action_id = action && action.id;
this.action_id = action_id;
},
start: function () {
var self = this;
+1
View File
@@ -786,6 +786,7 @@ instance.web.ViewManager = instance.web.Widget.extend({
hidden: this.flags.search_view === false,
disable_custom_filters: this.flags.search_disable_custom_filters,
$buttons: this.$('.oe-search-options'),
action: this.action,
};
var SearchView = instance.web.SearchView;
this.searchview = new SearchView(this, this.dataset, view_id, search_defaults, options);
+3 -3
View File
@@ -1228,7 +1228,7 @@ openerp.testing.section('search.filters.saved', {
templates: true
}, function (test) {
test('checkboxing', {asserts: 6}, function (instance, $fix, mock) {
var view = makeSearchView(instance);
var view = makeSearchView(instance, undefined, undefined, {action: {id: 1}});
mock('ir.filters:get_filters', function () {
return [{ name: "filter name", user_id: 42 }];
});
@@ -1266,7 +1266,7 @@ openerp.testing.section('search.filters.saved', {
});
});
test('toggling', {asserts: 2}, function (instance, $fix, mock) {
var view = makeSearchView(instance);
var view = makeSearchView(instance, undefined, undefined, {action: {id: 1}});
mock('ir.filters:get_filters', function () {
return [{name: 'filter name', user_id: 42, id: 1}];
});
@@ -1280,7 +1280,7 @@ openerp.testing.section('search.filters.saved', {
});
});
test('replacement', {asserts: 4}, function (instance, $fix, mock) {
var view = makeSearchView(instance);
var view = makeSearchView(instance, undefined, undefined, {action: {id: 1}});
mock('ir.filters:get_filters', function () {
return [
{name: 'f', user_id: 42, id: 1, context: {'private': 1}},