[FIX] web: do not render invisible filters in search view

In some cases, the web client may receive a search view with invisible
filters.  This is due to the way field_view_get works.  For
example, if there is a group on a filter, then this will be transformed
into an invisible attribute.

In that case, the search view should simply ignore the filter and not
display it.  This was broken in the recent control panel refactoring
(note that the search view lacked the possibility of testing that kind
of situation).

closes odoo/odoo#29430
This commit is contained in:
Géry Debongnie
2018-12-11 13:54:26 +00:00
parent 6c1445b24e
commit 13aae100e2
2 changed files with 26 additions and 0 deletions
@@ -199,6 +199,9 @@ var ControlPanelView = Factory.extend({
var groupNumber = 1;
_.each(preFilters, function (preFilter) {
if (preFilter.attrs && preFilter.attrs.invisible) {
return;
}
if (preFilter.tag !== currentTag || _.contains(['separator', 'field'], preFilter.tag)) {
if (currentGroup.length) {
if (currentTag === 'groupBy') {
@@ -330,5 +330,28 @@ QUnit.module('Views', {
"there should be two groups of a single field"
);
});
QUnit.module('Control Panel Rendering');
QUnit.test('invisible filters are not rendered', async function (assert) {
assert.expect(2);
var controlPanel = await createControlPanel({
model: 'partner',
arch: "<search>" +
"<filter name=\"filterA\" string=\"A\" domain=\"[]\"/>" +
"<filter name=\"filterB\" string=\"B\" invisible=\"1\" domain=\"[]\"/>" +
"</search>",
data: this.data,
searchMenuTypes: ['filter'],
context: {
search_disable_custom_filters: true,
},
});
testUtils.dom.click(controlPanel.$('.o_filters_menu_button'));
assert.containsOnce(controlPanel, '.o_menu_item a:contains("A")');
assert.containsNone(controlPanel, '.o_menu_item a:contains("B")');
controlPanel.destroy();
});
});
});