[IMP] stop using custom /web/searchview endpoints in search view
bzr revid: xmo@openerp.com-20121126093818-omxaj3qljolgq8qj
This commit is contained in:
parent
929a656619
commit
720f3faf93
|
@ -341,17 +341,19 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
|
||||||
if (this.headless) {
|
if (this.headless) {
|
||||||
this.ready.resolve();
|
this.ready.resolve();
|
||||||
} else {
|
} else {
|
||||||
var load_view = this.rpc("/web/searchview/load", {
|
var load_view = this.rpc("/web/view/load", {
|
||||||
model: this.model,
|
model: this.model,
|
||||||
view_id: this.view_id,
|
view_id: this.view_id,
|
||||||
context: this.dataset.get_context() });
|
view_type: 'search',
|
||||||
|
context: instance.web.pyeval.eval(
|
||||||
|
'context', this.dataset.get_context())
|
||||||
|
});
|
||||||
|
|
||||||
$.when(load_view)
|
$.when(load_view).then(function (r) {
|
||||||
.then(function(r) {
|
return self.search_view_loaded(r)
|
||||||
self.search_view_loaded(r)
|
}).fail(function () {
|
||||||
}, function () {
|
self.ready.reject.apply(null, arguments);
|
||||||
self.ready.reject.apply(null, arguments);
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.web.bus.on('click', this, function(ev) {
|
instance.web.bus.on('click', this, function(ev) {
|
||||||
|
@ -615,16 +617,16 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
|
||||||
|
|
||||||
search_view_loaded: function(data) {
|
search_view_loaded: function(data) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.fields_view = data.fields_view;
|
this.fields_view = data;
|
||||||
if (data.fields_view.type !== 'search' ||
|
if (data.type !== 'search' ||
|
||||||
data.fields_view.arch.tag !== 'search') {
|
data.arch.tag !== 'search') {
|
||||||
throw new Error(_.str.sprintf(
|
throw new Error(_.str.sprintf(
|
||||||
"Got non-search view after asking for a search view: type %s, arch root %s",
|
"Got non-search view after asking for a search view: type %s, arch root %s",
|
||||||
data.fields_view.type, data.fields_view.arch.tag));
|
data.type, data.arch.tag));
|
||||||
}
|
}
|
||||||
this.make_widgets(
|
this.make_widgets(
|
||||||
data.fields_view['arch'].children,
|
data['arch'].children,
|
||||||
data.fields_view.fields);
|
data.fields);
|
||||||
|
|
||||||
this.add_common_inputs();
|
this.add_common_inputs();
|
||||||
|
|
||||||
|
@ -632,6 +634,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
|
||||||
var drawer_started = $.when.apply(
|
var drawer_started = $.when.apply(
|
||||||
null, _(this.select_for_drawer()).invoke(
|
null, _(this.select_for_drawer()).invoke(
|
||||||
'appendTo', this.$('.oe_searchview_drawer')));
|
'appendTo', this.$('.oe_searchview_drawer')));
|
||||||
|
|
||||||
|
|
||||||
// load defaults
|
// load defaults
|
||||||
var defaults_fetched = $.when.apply(null, _(this.inputs).invoke(
|
var defaults_fetched = $.when.apply(null, _(this.inputs).invoke(
|
||||||
|
@ -1506,16 +1509,10 @@ instance.web.search.CustomFilters = instance.web.search.Input.extend({
|
||||||
this.$el.on('click', 'h4', function () {
|
this.$el.on('click', 'h4', function () {
|
||||||
self.$el.toggleClass('oe_opened');
|
self.$el.toggleClass('oe_opened');
|
||||||
});
|
});
|
||||||
// FIXME: local eval of domain and context to get rid of special endpoint
|
return this.model.call('get_filters', [this.view.model])
|
||||||
return this.rpc('/web/searchview/get_filters', {
|
|
||||||
model: this.view.model
|
|
||||||
})
|
|
||||||
.then(this.proxy('set_filters'))
|
.then(this.proxy('set_filters'))
|
||||||
.then(function () {
|
.done(function () { self.is_ready.resolve(); })
|
||||||
self.is_ready.resolve(null);
|
.fail(function () { self.is_ready.reject.apply(self.is_ready, arguments); });
|
||||||
}, function () {
|
|
||||||
self.is_ready.reject();
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Special implementation delaying defaults until CustomFilters is loaded
|
* Special implementation delaying defaults until CustomFilters is loaded
|
||||||
|
@ -1708,7 +1705,7 @@ instance.web.search.Advanced = instance.web.search.Input.extend({
|
||||||
});
|
});
|
||||||
return $.when(
|
return $.when(
|
||||||
this._super(),
|
this._super(),
|
||||||
this.rpc("/web/searchview/fields_get", {model: this.view.model}).done(function(data) {
|
new instance.web.Model(this.view.model).call('fields_get').done(function(data) {
|
||||||
self.fields = _.extend({
|
self.fields = _.extend({
|
||||||
id: { string: 'ID', type: 'id' }
|
id: { string: 'ID', type: 'id' }
|
||||||
}, data.fields);
|
}, data.fields);
|
||||||
|
|
|
@ -152,9 +152,9 @@ var makeSearchView = function (instance, dummy_widget_attributes, defaults) {
|
||||||
instance.dummy = {};
|
instance.dummy = {};
|
||||||
instance.dummy.DummyWidget = instance.web.search.Field.extend(
|
instance.dummy.DummyWidget = instance.web.search.Field.extend(
|
||||||
dummy_widget_attributes || {});
|
dummy_widget_attributes || {});
|
||||||
if (!('/web/searchview/load' in instance.session.responses)) {
|
if (!('/web/view/load' in instance.session.responses)) {
|
||||||
instance.session.responses['/web/searchview/load'] = function () {
|
instance.session.responses['/web/view/load'] = function () {
|
||||||
return {fields_view: {
|
return {
|
||||||
type: 'search',
|
type: 'search',
|
||||||
fields: {
|
fields: {
|
||||||
dummy: {type: 'char', string: "Dummy"}
|
dummy: {type: 'char', string: "Dummy"}
|
||||||
|
@ -171,13 +171,13 @@ var makeSearchView = function (instance, dummy_widget_attributes, defaults) {
|
||||||
children: []
|
children: []
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
instance.session.responses['/web/searchview/get_filters'] = function () {
|
instance.session.responses['ir.filters:get_filters'] = function () {
|
||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
instance.session.responses['/web/searchview/fields_get'] = function () {
|
instance.session.responses['dummy.model:fields_get'] = function () {
|
||||||
return {fields: {
|
return {fields: {
|
||||||
dummy: {type: 'char', string: 'Dummy'}
|
dummy: {type: 'char', string: 'Dummy'}
|
||||||
}};
|
}};
|
||||||
|
@ -890,9 +890,9 @@ openerp.testing.section('filters', {
|
||||||
rpc: 'mock',
|
rpc: 'mock',
|
||||||
templates: true,
|
templates: true,
|
||||||
setup: function (instance, $s, mock) {
|
setup: function (instance, $s, mock) {
|
||||||
mock('/web/searchview/load', function () {
|
mock('/web/view/load', function () {
|
||||||
// view with a single group of filters
|
// view with a single group of filters
|
||||||
return {fields_view: {
|
return {
|
||||||
type: 'search',
|
type: 'search',
|
||||||
fields: {},
|
fields: {},
|
||||||
arch: {
|
arch: {
|
||||||
|
@ -915,7 +915,7 @@ openerp.testing.section('filters', {
|
||||||
children: []
|
children: []
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, function (test) {
|
}, function (test) {
|
||||||
|
@ -992,7 +992,7 @@ openerp.testing.section('saved_filters', {
|
||||||
}, function (test) {
|
}, function (test) {
|
||||||
test('checkboxing', {asserts: 6}, function (instance, $fix, mock) {
|
test('checkboxing', {asserts: 6}, function (instance, $fix, mock) {
|
||||||
var view = makeSearchView(instance);
|
var view = makeSearchView(instance);
|
||||||
mock('/web/searchview/get_filters', function () {
|
mock('ir.filters:get_filters', function () {
|
||||||
return [{ name: "filter name", user_id: 42 }];
|
return [{ name: "filter name", user_id: 42 }];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1015,7 +1015,7 @@ openerp.testing.section('saved_filters', {
|
||||||
});
|
});
|
||||||
test('removal', {asserts: 1}, function (instance, $fix, mock) {
|
test('removal', {asserts: 1}, function (instance, $fix, mock) {
|
||||||
var view = makeSearchView(instance);
|
var view = makeSearchView(instance);
|
||||||
mock('/web/searchview/get_filters', function () {
|
mock('ir.filters:get_filters', function () {
|
||||||
return [{ name: "filter name", user_id: 42 }];
|
return [{ name: "filter name", user_id: 42 }];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue