From b1d80841fc73a3ad5522629328352fe8ad7cd1c2 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 6 Mar 2019 13:08:04 +0000 Subject: [PATCH] [FIX] base: allow to t-raw="0" with empty content Before this commit, when doing `` to print the t-called content, it was printing "[]" if the content was left empty. closes odoo/odoo#31668 Signed-off-by: Quentin Smetz (qsm) --- odoo/addons/base/models/qweb.py | 44 ++++++++++++++------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/odoo/addons/base/models/qweb.py b/odoo/addons/base/models/qweb.py index de5d3cf9e2b..723ff875ed4 100644 --- a/odoo/addons/base/models/qweb.py +++ b/odoo/addons/base/models/qweb.py @@ -1660,32 +1660,26 @@ class QWeb(object): def _compile_expr0(self, expr): if expr == "0": - # values.get(0) and u''.join(values[0]) - return ast.BoolOp( - op=ast.And(), - values=[ - ast.Call( - func=ast.Attribute( - value=ast.Name(id='values', ctx=ast.Load()), - attr='get', - ctx=ast.Load() - ), - args=[ast.Num(0)], keywords=[], - starargs=None, kwargs=None + # u''.join(values.get(0, [])) + return ast.Call( + func=ast.Attribute( + value=ast.Str(u''), + attr='join', + ctx=ast.Load() + ), + args=[ + ast.Call( + func=ast.Attribute( + value=ast.Name(id='values', ctx=ast.Load()), + attr='get', + ctx=ast.Load() ), - ast.Call( - func=ast.Attribute( - value=ast.Str(u''), - attr='join', - ctx=ast.Load() - ), - args=[ - self._values_var(ast.Num(0), ctx=ast.Load()) - ], - keywords=[], starargs=None, kwargs=None - ) - ] - ) + args=[ast.Num(0), ast.List(elts=[], ctx=ast.Load())], keywords=[], + starargs=None, kwargs=None + ) + ], + keywords=[], starargs=None, kwargs=None + ) return self._compile_expr(expr) def _compile_format(self, f):