Skip to content

Commit

Permalink
[FIX] autocomplete: fix pivot group autocomplete
Browse files Browse the repository at this point in the history
The computation to autocomplete pivot group values was only supporting
string-like group values. If a user were to write some random input,
like a number, the code would crash.

closes #4420

Task: 3976271
X-original-commit: e3cb344
Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
  • Loading branch information
rrahir committed Jun 11, 2024
1 parent 7accb8f commit 82cacd7
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/registries/auto_completes/pivot_auto_complete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,19 @@ autoCompleteProviders.add("pivot_group_values", {
if (!groupByField) {
return;
}
return dataSource.getPossibleFieldValues(groupByField.split(":")[0]).map(({ value, label }) => {
const isString = typeof value === "string";
const text = isString ? `"${value}"` : value.toString();
const color = isString ? tokenColors.STRING : tokenColors.NUMBER;
return {
text,
description: label,
htmlContent: [{ value: text, color }],
fuzzySearchKey: value + label,
};
});
return dataSource
.getPossibleFieldValues(groupByField.toString().split(":")[0])
.map(({ value, label }) => {
const isString = typeof value === "string";
const text = isString ? `"${value}"` : value.toString();
const color = isString ? tokenColors.STRING : tokenColors.NUMBER;
return {
text,
description: label,
htmlContent: [{ value: text, color }],
fuzzySearchKey: value + label,
};
});
},
selectProposal: insertTokenAfterArgSeparator,
});
Expand Down

0 comments on commit 82cacd7

Please sign in to comment.