summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorArthur Maniet <arthurmaniet@me.com>2015-02-04 13:45:19 +0100
committerXavier Morel <xmo@odoo.com>2015-02-05 13:08:15 +0100
commitf0cefa72325cabcd2bff1952816a84a380dc6e2f (patch)
tree0d11938b1c0376d6085e234df522d67879dc43db /addons/web/static/src
parent691254cbfe0d4c64762d2d1c2c5e3b0ad2c5423b (diff)
[ADD] py.js: len() and truthiness on lists, tuples and dicts
* use new support to colorize reconciled bank statement lines * fixes tokenization of ``is not`` to not blow up on ``not foo`` * improves calling code to get truthiness of evaluated expression instead of truthiness of javascript-equivalent objects: an empty list is falsy in Python but truthy in javascript, since the evaluated expression is in Python one would expect Python truthiness rules without having to manually convert to boolean closes #5070
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/view_list.js4
-rw-r--r--addons/web/static/src/js/view_tree.js2
2 files changed, 3 insertions, 3 deletions
diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js
index 0e446fb323e..135f73d2ce2 100644
--- a/addons/web/static/src/js/view_list.js
+++ b/addons/web/static/src/js/view_list.js
@@ -182,7 +182,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
pair = this.fonts[i];
var font = pair[0];
expression = pair[1];
- if (py.evaluate(expression, context).toJSON()) {
+ if (py.PY_isTrue(py.evaluate(expression, context))) {
switch(font) {
case 'bold':
style += 'font-weight: bold;';
@@ -203,7 +203,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
pair = this.colors[i];
var color = pair[0];
expression = pair[1];
- if (py.evaluate(expression, context).toJSON()) {
+ if (py.PY_isTrue(py.evaluate(expression, context))) {
return style += 'color: ' + color + ';';
}
// TODO: handle evaluation errors
diff --git a/addons/web/static/src/js/view_tree.js b/addons/web/static/src/js/view_tree.js
index aac7198f2c3..45cc183511a 100644
--- a/addons/web/static/src/js/view_tree.js
+++ b/addons/web/static/src/js/view_tree.js
@@ -145,7 +145,7 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
var pair = this.colors[i],
color = pair[0],
expression = pair[1];
- if (py.evaluate(expression, context).toJSON()) {
+ if (py.PY_isTrue(py.evaluate(expression, context))) {
return 'color: ' + color + ';';
}
// TODO: handle evaluation errors