[FIX] web: py_js: add "true"/"false" in context
Before this commit, py_js was unabled to evaluate expressions containing "true" or "false" (boolean values, JS syntax), which seems reasonnable for a python interpreter. However in Odoo, we often use that syntax in modifiers (e.g. required="true"). For that reason, we need to add those two keywords in the evaluation context. Part-of: odoo/odoo#87522
This commit is contained in:
@@ -58,4 +58,7 @@ export const BUILTINS = {
|
||||
},
|
||||
|
||||
relativedelta: PyRelativeDelta,
|
||||
|
||||
true: true,
|
||||
false: false,
|
||||
};
|
||||
|
||||
@@ -145,6 +145,11 @@ QUnit.module("py", {}, () => {
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("true and false available in context", (assert) => {
|
||||
assert.strictEqual(evaluateExpr("true"), true);
|
||||
assert.strictEqual(evaluateExpr("false"), false);
|
||||
});
|
||||
|
||||
QUnit.test("throw error if name is not defined", (assert) => {
|
||||
assert.throws(() => evaluateExpr("a"));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user