From 82cacd774309503fd2a75eb1a01fb1daeb44e1c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Rahir=20=28rar=29?= Date: Tue, 11 Jun 2024 08:39:46 +0200 Subject: [PATCH] [FIX] autocomplete: fix pivot group autocomplete 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 odoo/o-spreadsheet#4420 Task: 3976271 X-original-commit: e3cb344b3b9d8b1f3a1fd5d71f6b2ec13ec8e20c Signed-off-by: Pierre Rousseau (pro) --- .../auto_completes/pivot_auto_complete.ts | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/registries/auto_completes/pivot_auto_complete.ts b/src/registries/auto_completes/pivot_auto_complete.ts index 54625fa2c8..7e6215fbf0 100644 --- a/src/registries/auto_completes/pivot_auto_complete.ts +++ b/src/registries/auto_completes/pivot_auto_complete.ts @@ -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, });