From b558cb7996b1de385f6bf7cb3918f0e37cee69fe Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 10 Jul 2020 10:09:35 +0000 Subject: [PATCH] [FIX] web: qweb old inheritance mechanism Before this commit, defining a extension of a template by using the combination of directives 't-name' and 't-extend' ignored potential extensions that could have been defined beforehand. For instance, let's assume the following templates. ```xml
1
2 b ``` Rendering template "b" displayed "1b" whereas we would expect "2b". Moreover, when the extended template is itself an extension of another template: ```xml
a
b c ``` Rendering template "a" displayed "a", template "b" displayed "ab", but template "c" displayed "ac", whereas we would expect "abc". With this commit, other extensions done to a template are kept when a new extension is defined. It relies on the templates order, and takes into account all extensions that have *already* been defined. This is exactly how the new qweb inheritance mechanism (using 't-inherit' and 't-inherit-mode') behaves. closes odoo/odoo#54315 Signed-off-by: Lucas Perais (lpe) --- .../web/static/lib/qweb/qweb-test-extend.xml | 21 ++++++++++++++++++- addons/web/static/lib/qweb/qweb2.js | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/addons/web/static/lib/qweb/qweb-test-extend.xml b/addons/web/static/lib/qweb/qweb-test-extend.xml index dfd0ec46940..f8a24c4ef8e 100644 --- a/addons/web/static/lib/qweb/qweb-test-extend.xml +++ b/addons/web/static/lib/qweb/qweb-test-extend.xml @@ -37,7 +37,26 @@
  • [[cloned template]]
  • one
  • [[cloned template]]
  • +
    • 1
    • 2
    • 3
    • [[cloned template]]
    [[end]]
    ]]>
    + + +
    Hi
    +
    + + World + + + Hello + + Hi +]]> + HiWorld +]]> + HelloWorld +]]> diff --git a/addons/web/static/lib/qweb/qweb2.js b/addons/web/static/lib/qweb/qweb2.js index 2cfd2286cbc..d2a367f1c33 100644 --- a/addons/web/static/lib/qweb/qweb2.js +++ b/addons/web/static/lib/qweb/qweb2.js @@ -268,6 +268,7 @@ QWeb2.Engine = (function() { return this.tools.exception("Can't clone undefined template " + extend); } this.templates[name] = this.templates[extend].cloneNode(true); + this.extend_templates[name] = (this.extend_templates[extend] || []).slice(); extend = name; name = undefined; }