From cb30d0ef0e2f113807c64fc99013efbd79e414e0 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Wed, 6 Jul 2016 14:55:10 +0200 Subject: [PATCH] [FIX] web: qweb: correctly set `preprocess_node` on qweb engine issue: xml template are not translated anymore rev d56b35e2 moved qweb code inside the `qweb.js` file and also changed the behavior with the introduction of a `QWeb` factory returning instances of qweb rendering engine. However, we have to set on the rendering engine instance a `preprocess_node` function that will translate the qweb templates. The solution for this issue (also introduced with rev d56b35e2) was to set this function on the prototype of the QWeb factory, and it was obviously not enough as it has to be attached to the rendering engine instance. In order to benefit from the fact that the `preprocess_node` function is attached to the prototype of the QWeb factory, we could attach it to the rendering engine instance with something like `qweb.preprocessed_node = this.preprocessed_node`, however i find that conceptually attaching a translate function to a factory does not make sense, si i simply made `preprocess_node` a free function and i set it on rendering engine instance. --- addons/web/static/src/js/framework/qweb.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/framework/qweb.js b/addons/web/static/src/js/framework/qweb.js index 39066216737..50742075e05 100644 --- a/addons/web/static/src/js/framework/qweb.js +++ b/addons/web/static/src/js/framework/qweb.js @@ -16,10 +16,11 @@ function QWeb(debug, default_dict) { 'csrf_token': odoo.csrf_token, }); qweb.debug = debug; + qweb.preprocess_node = preprocess_node; return qweb; } -QWeb.prototype.preprocess_node = function() { +function preprocess_node() { // Note that 'this' is the Qweb Node switch (this.node.nodeType) { case Node.TEXT_NODE: @@ -43,7 +44,7 @@ QWeb.prototype.preprocess_node = function() { } } } -}; +} return QWeb;