From 27ff895dfd92619d496f67c8b11cb76277bf62d2 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 26 Apr 2017 16:28:36 +0200 Subject: [PATCH] [IMP] web: extend qweb to allow dynamic templates in t-call Before this change the t-call can use only receive a literal as parameters: This call render the template 'template.name17' with the current context. Now, we can defined an expression with braces (same syntax that t-attf): This call render the template 'template.name17' with the current context. This change allows for greater flexibility for applications using qweb. (The performance due to this change is unchanged during rendering time.) --- addons/web/static/lib/qweb/qweb-test-call.xml | 5 +++++ addons/web/static/lib/qweb/qweb2.js | 4 ++-- odoo/addons/base/ir/ir_qweb/qweb.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/web/static/lib/qweb/qweb-test-call.xml b/addons/web/static/lib/qweb/qweb-test-call.xml index 783172c73bd..45a65eabce9 100644 --- a/addons/web/static/lib/qweb/qweb-test-call.xml +++ b/addons/web/static/lib/qweb/qweb-test-call.xml @@ -55,4 +55,9 @@ ok + + + + + ok diff --git a/addons/web/static/lib/qweb/qweb2.js b/addons/web/static/lib/qweb/qweb2.js index 378c5eb6023..c4bb7128e9b 100644 --- a/addons/web/static/lib/qweb/qweb2.js +++ b/addons/web/static/lib/qweb/qweb2.js @@ -785,9 +785,9 @@ QWeb2.Element = (function() { }, compile_action_call : function(value) { if (this.children.length === 0) { - return this.top("r.push(context.engine.tools.call(context, " + (this.engine.tools.js_escape(value)) + ", dict));"); + return this.top("r.push(context.engine.tools.call(context, " + (this.string_interpolation(value)) + ", dict));"); } else { - this.top("r.push(context.engine.tools.call(context, " + (this.engine.tools.js_escape(value)) + ", dict, null, function(context, dict) {"); + this.top("r.push(context.engine.tools.call(context, " + (this.string_interpolation(value)) + ", dict, null, function(context, dict) {"); this.bottom("}));"); this.indent(); this.top("var r = [];"); diff --git a/odoo/addons/base/ir/ir_qweb/qweb.py b/odoo/addons/base/ir/ir_qweb/qweb.py index b395dfb7698..14a0a54fbd9 100644 --- a/odoo/addons/base/ir/ir_qweb/qweb.py +++ b/odoo/addons/base/ir/ir_qweb/qweb.py @@ -1475,7 +1475,7 @@ class QWeb(object): ctx=ast.Load() ), args=[ - ast.Str(str(tmpl)), + self._compile_format(str(tmpl)), ast.Name(id=name_options, ctx=ast.Load()), ], keywords=[], starargs=None, kwargs=None