[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
cherry-pick of 13aae100e2
closes odoo/odoo#29965
This commit is contained in:
committed by
Christophe Monniez
parent
70f35620ba
commit
68eefe3cee
@@ -197,6 +197,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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user