documentation/wowl_markdown_doc/python_interpreter.md
Géry Debongnie eff7c05465 [DOC] add master-wowl doc (UNFINISHED)
I know, the doc is still in md, it was only temporary. we will convert
it to rst someday
2021-05-31 15:29:27 +02:00

1004 B

Python Interpreter

Overview

The Odoo web client features a built-in small python interpreter. Its purpose is to evaluate small python expressions. This is important, because views in Odoo have modifiers written in python, but they need to be evaluated by the browser.

Example:

evaluate("1 + 2*{'a': 1}.get('b', 54) + v", { v: 33 }); // returns 142

API

The py javascript code exports 5 functions:

Function Description
tokenize(expr: string) -> Token[] convert a string into a list of tokens
parse(tokens: Token[]) -> AST parse a list of tokens into an AST
parseExpr(expr: string) -> AST tokenize and parse an expression
evaluate(ast: AST) -> any evaluate an AST
evaluateExpr(expr: string) -> any tokenize, parse and evaluate an expression