[FIX] update tests and change search logic (webclient)
authorGéry Debongnie <ged@odoo.com>
Thu, 20 Nov 2014 13:58:10 +0000 (14:58 +0100)
committerGéry Debongnie <ged@odoo.com>
Thu, 20 Nov 2014 13:58:10 +0000 (14:58 +0100)
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.

addons/web/static/src/js/search.js
addons/web/static/src/js/views.js
addons/web/static/test/search.js

index c4627ef..2859c30 100644 (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;
index 1c41b04..35c424c 100644 (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);
index d5d2eed..5ec4608 100644 (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}},