[FIX] spreadsheet: un-escape filter name
Steps to reproduce:
- insert a global filter with double quotes in its name (e.g. my "special"
filter)
- reference that filter with ODOO.FILTER.VALUE (remember you have to escape
the " in the formula with a backslash \
=ODOO.FILTER.VALUE("my \"special\" filter")
=> the filter is not found
closes odoo/odoo#153337
Task: 3697855
X-original-commit: 83826d3546ff584c5ff22021370f572787d032bc
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
This commit is contained in:
@@ -47,7 +47,8 @@ const ODOO_FILTER_VALUE = {
|
||||
args: [arg("filter_name (string)", _t("The label of the filter whose value to return."))],
|
||||
category: "Odoo",
|
||||
compute: function (filterName) {
|
||||
return this.getters.getFilterDisplayValue(filterName);
|
||||
const unEscapedFilterName = toString(filterName).replaceAll('\\"', '"');
|
||||
return this.getters.getFilterDisplayValue(unEscapedFilterName);
|
||||
},
|
||||
returns: ["STRING"],
|
||||
};
|
||||
|
||||
@@ -944,6 +944,21 @@ QUnit.module("spreadsheet > Global filters model", {}, () => {
|
||||
assert.verifySteps(["read_1", "read_2"]);
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"ODOO.FILTER.VALUE with escaped quotes in the filter label",
|
||||
async function (assert) {
|
||||
const model = await createModelWithDataSource();
|
||||
await addGlobalFilter(model, {
|
||||
id: "42",
|
||||
type: "text",
|
||||
label: 'my "special" filter',
|
||||
defaultValue: "Jean-Jacques",
|
||||
});
|
||||
setCellContent(model, "A1", '=ODOO.FILTER.VALUE("my \\"special\\" filter")');
|
||||
assert.equal(getCellValue(model, "A1"), "Jean-Jacques");
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"ODOO.FILTER.VALUE formulas are updated when filter label is changed",
|
||||
async function (assert) {
|
||||
|
||||
Reference in New Issue
Block a user