[FIX] web: SelectCreateDialog uses the domain of the view when searching
before this fix: the domain is used when opening the dialog but it is not used if the user update the filter or the group_by.
This commit is contained in:
@@ -327,7 +327,6 @@ var SelectCreateDialog = ViewDialog.extend({
|
||||
var searchview = new SearchView(this, this.dataset, fields_views.search, options);
|
||||
searchview.prependTo($header).done(function () {
|
||||
var d = searchview.build_search_data();
|
||||
d.domains = d.domains.concat([self.domain]);
|
||||
if (self.initial_ids) {
|
||||
d.domains.push([["id", "in", self.initial_ids]]);
|
||||
self.initial_ids = undefined;
|
||||
@@ -388,8 +387,9 @@ var SelectCreateDialog = ViewDialog.extend({
|
||||
contexts: [this.context].concat(contexts),
|
||||
group_by_seq: groupbys || []
|
||||
});
|
||||
var context = _.omit(results.context, function (value, key) { return key.indexOf('search_default_') === 0; });
|
||||
return {
|
||||
context: results.context,
|
||||
context: context,
|
||||
domain: results.domain,
|
||||
groupBy: results.group_by,
|
||||
};
|
||||
|
||||
@@ -10,10 +10,14 @@ QUnit.module('Views', {
|
||||
this.data = {
|
||||
partner: {
|
||||
fields: {
|
||||
display_name: { string: "Displayed name", type: "char" },
|
||||
foo: {string: "Foo", type: 'char'},
|
||||
bar: {string: "Bar", type: "boolean"},
|
||||
},
|
||||
records: [
|
||||
{id: 1, foo: 'blip',},
|
||||
{id: 1, foo: 'blip', display_name: 'blipblip', bar: true},
|
||||
{id: 2, foo: 'ta tata ta ta', display_name: 'macgyver', bar: false},
|
||||
{id: 3, foo: 'piou piou', display_name: "Jack O'Neill", bar: true},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -63,6 +67,79 @@ QUnit.module('Views', {
|
||||
dialog.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('SelectCreateDialog use domain, group_by and search default', function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
var search = 0;
|
||||
var parent = createParent({
|
||||
data: this.data,
|
||||
archs: {
|
||||
'partner,false,list':
|
||||
'<tree string="Partner">' +
|
||||
'<field name="display_name"/>' +
|
||||
'<field name="foo"/>' +
|
||||
'</tree>',
|
||||
'partner,false,search':
|
||||
'<search>' +
|
||||
'<field name="foo" filter_domain="[(\'display_name\',\'ilike\',self), (\'foo\',\'ilike\',self)]"/>' +
|
||||
'<group expand="0" string="Group By">' +
|
||||
'<filter name="groupby_bar" context="{\'group_by\' : \'bar\'}"/>' +
|
||||
'</group>' +
|
||||
'</search>',
|
||||
},
|
||||
mockRPC: function (route, args) {
|
||||
search++;
|
||||
if (search === 1 && args.method === 'read_group') {
|
||||
assert.deepEqual(args.kwargs, {
|
||||
context: {group_by: "bar"},
|
||||
domain: [["display_name","like","a"], ["display_name","ilike","piou"], ["foo","ilike","piou"]],
|
||||
fields:["display_name","foo","bar"],
|
||||
groupby:["bar"],
|
||||
lazy: true
|
||||
}, "should search with the complete domain (domain + search), and group by 'bar'");
|
||||
}
|
||||
if (search === 2 && route === '/web/dataset/search_read') {
|
||||
assert.deepEqual(args, {
|
||||
context: {},
|
||||
domain: [["display_name","like","a"], ["display_name","ilike","piou"], ["foo","ilike","piou"]],
|
||||
fields:["display_name","foo"],
|
||||
model: "partner",
|
||||
limit: 80,
|
||||
sort: ""
|
||||
}, "should search with the complete domain (domain + search)");
|
||||
}
|
||||
if (search === 3 && route === '/web/dataset/search_read') {
|
||||
assert.deepEqual(args, {
|
||||
context: {},
|
||||
domain: [["display_name","like","a"]],
|
||||
fields:["display_name","foo"],
|
||||
model: "partner",
|
||||
limit: 80,
|
||||
sort: ""
|
||||
}, "should search with the domain");
|
||||
}
|
||||
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
});
|
||||
|
||||
var dialog = new dialogs.SelectCreateDialog(parent, {
|
||||
no_create: true,
|
||||
readonly: true,
|
||||
res_model: 'partner',
|
||||
domain: [['display_name', 'like', 'a']],
|
||||
context: {
|
||||
search_default_groupby_bar: true,
|
||||
search_default_foo: 'piou',
|
||||
},
|
||||
}).open();
|
||||
|
||||
dialog.$('.o_searchview_facet:contains(groupby_bar) .o_facet_remove').click();
|
||||
dialog.$('.o_searchview_facet .o_facet_remove').click();
|
||||
|
||||
dialog.destroy();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user