diff --git a/addons/web/static/src/search/search_arch_parser.js b/addons/web/static/src/search/search_arch_parser.js
index 4414da11c8a..4556c9283ff 100644
--- a/addons/web/static/src/search/search_arch_parser.js
+++ b/addons/web/static/src/search/search_arch_parser.js
@@ -25,6 +25,16 @@ const getContextGroubBy = (context) => {
}
};
+function reduceType(type) {
+ if (type === "dateFilter") {
+ return "filter";
+ }
+ if (type === "dateGroupBy") {
+ return "groupBy";
+ }
+ return type;
+}
+
export class SearchArchParser extends XMLParser {
constructor(searchViewDescription, searchDefaults = {}, searchPanelDefaults = {}) {
super();
@@ -86,7 +96,7 @@ export class SearchArchParser extends XMLParser {
pushGroup(tag = null) {
if (this.currentGroup.length) {
- if (this.currentTag && ["groupBy", "dateGroupBy"].includes(this.currentTag)) {
+ if (this.currentTag === "groupBy") {
this.pregroupOfGroupBys.push(...this.currentGroup);
} else {
this.preSearchItems.push(this.currentGroup);
@@ -189,8 +199,8 @@ export class SearchArchParser extends XMLParser {
preSearchItem.context = context;
}
}
- if (preSearchItem.type !== this.currentTag) {
- this.pushGroup(preSearchItem.type);
+ if (reduceType(preSearchItem.type) !== this.currentTag) {
+ this.pushGroup(reduceType(preSearchItem.type));
}
if (preSearchItem.type === "filter") {
if (node.hasAttribute("date")) {
diff --git a/addons/web/static/tests/search/search_model_tests.js b/addons/web/static/tests/search/search_model_tests.js
index abe76fb90a8..92333c830b4 100644
--- a/addons/web/static/tests/search/search_model_tests.js
+++ b/addons/web/static/tests/search/search_model_tests.js
@@ -530,6 +530,66 @@ QUnit.module("Search", (hooks) => {
]);
});
+ QUnit.test("parsing a filter and a dateFilter", async function (assert) {
+ assert.expect(1);
+ const model = await makeSearchModel({
+ serverData,
+ searchViewArch: `
+
+
+
+
+ `,
+ });
+ const groupNumbers = model.getSearchItems(() => true).map((i) => i.groupNumber);
+ assert.deepEqual(groupNumbers, [1, 1]);
+ });
+
+ QUnit.test("parsing a groupBy and a dateGroupBy", async function (assert) {
+ assert.expect(1);
+ const model = await makeSearchModel({
+ serverData,
+ searchViewArch: `
+
+
+
+
+ `,
+ });
+ const groupNumbers = model.getSearchItems(() => true).map((i) => i.groupNumber);
+ assert.deepEqual(groupNumbers, [1, 1]);
+ });
+
+ QUnit.test("parsing a filter and a groupBy", async function (assert) {
+ assert.expect(1);
+ const model = await makeSearchModel({
+ serverData,
+ searchViewArch: `
+
+
+
+
+ `,
+ });
+ const groupNumbers = model.getSearchItems(() => true).map((i) => i.groupNumber);
+ assert.deepEqual(groupNumbers, [1, 2]);
+ });
+
+ QUnit.test("parsing a groupBy and a filter", async function (assert) {
+ assert.expect(1);
+ const model = await makeSearchModel({
+ serverData,
+ searchViewArch: `
+
+
+
+
+ `,
+ });
+ const groupNumbers = model.getSearchItems(() => true).map((i) => i.groupNumber);
+ assert.deepEqual(groupNumbers, [2, 1]);
+ });
+
QUnit.test("process search default group by", async function (assert) {
assert.expect(1);
const model = await makeSearchModel({