diff options
| author | Cedric Snauwaert <csn@openerp.com> | 2019-07-03 08:58:30 +0000 |
|---|---|---|
| committer | Cedric Snauwaert <csn@openerp.com> | 2019-07-09 07:45:42 +0000 |
| commit | 9cab694bf594f6c7c8d795174d9159ac82f526b2 (patch) | |
| tree | 59c3726d041e72f92eb40d7b123d96e63eb26445 /addons/web/static/lib/py.js | |
| parent | 38753f95d9890171e8c9d81f29ae0b1b1eafa9cc (diff) | |
[IMP] web: add simple calculator on numeric fields
Add a new behavior to numeric fields, possibility to enter value manually or to use a simple arithmetic expression that will be evaluated.
Example: =20+3*2
In order for the computation of the arithmetic expression to be done, the value needs to starts with = and then an expression can be entered. We only support the basics mathematical operations + - * / ( ) ^
User locale and digits separator are taken into account. If the value entered can't be evaluated to a numeric, the field will be displayed in error.
closes odoo/odoo#34538
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/lib/py.js')
| -rw-r--r-- | addons/web/static/lib/py.js/lib/py.js | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/addons/web/static/lib/py.js/lib/py.js b/addons/web/static/lib/py.js/lib/py.js index 60b80a7f439..645e668f5c1 100644 --- a/addons/web/static/lib/py.js/lib/py.js +++ b/addons/web/static/lib/py.js/lib/py.js @@ -882,6 +882,12 @@ var py = {}; } return py.float.fromJSON(this._value * other._value); }, + __pow__: function (other) { + if (!py.PY_isInstance(other, py.float)) { + return py.NotImplemented; + } + return py.float.fromJSON(this._value ** other._value); + }, __div__: function (other) { if (!py.PY_isInstance(other, py.float)) { return py.NotImplemented; |
