summaryrefslogtreecommitdiff
path: root/addons/web/controllers
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2019-10-28 13:58:16 +0000
committerLucas Perais (lpe) <lpe@odoo.com>2019-12-04 13:06:52 +0000
commit96ab29c9873ee3d0f603068c6bc0c2d4056a3081 (patch)
tree4890b03a55293187d5e28569472e2990a7ca6950 /addons/web/controllers
parent1ae66862d5570ebdb97ba0301ff591c27b969254 (diff)
[IMP] web: template inheritance respects XPATH specs
At the conception of this feature it has been intentionally thought that the behavior for static templates should resemble what is done for ir.ui.view While keeping the general previous behavior (and this is important) A little bit of context for ir.ui.view They are defined as XML's, but end up as python objects Their meta-data (id, name, inheritance specs...) are thus present in their XML definition, but end up as part of python objects members Hence, the final, business, usable arch is free of those meta-data and is left only with business-relevant dom nodes The static inheritance feature was backed with those ideas but inherently encountered the issue that, for them, the meta-data also end up in the business dom, since they are at no point considered as plain objects. Decision has been made, back then, to exclude the root node that holds the metadata, to be at all targeted by any XPATH This decision is now challenged as the specs of XPATH should be respected This commit consequently introduces the root node as any other It can be replaced, and will be targeted by `expr="."` or `expr="//NODE_TAG"` The few attributes that are necessary to define them are kept across inheritance cycles though.
Diffstat (limited to 'addons/web/controllers')
-rw-r--r--addons/web/controllers/main.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py
index 24451c90e89..0ae52465604 100644
--- a/addons/web/controllers/main.py
+++ b/addons/web/controllers/main.py
@@ -509,15 +509,12 @@ class HomeStaticTemplateHelpers(object):
# After several performance tests, we found out that deepcopy is the most efficient
# solution in this case (compared with copy, xpath with '.' and stringifying).
parent_tree = copy.deepcopy(self.template_dict[parent_addon][parent_name])
- parent_tag = parent_tree.tag
- # replace temporarily the parent tag so it is never the target of the inheritance
- parent_tree.tag = 't'
+
xpaths = list(template_tree)
if self.debug and inherit_mode == self.EXTENSION_MODE:
for xpath in xpaths:
xpath.insert(0, etree.Comment(" Modified by %s from %s " % (template_name, addon)))
inherited_template = apply_inheritance_specs(parent_tree, xpaths)
- inherited_template.tag = parent_tag
if inherit_mode == self.PRIMARY_MODE: # New template_tree: A' = B(A)
inherited_template.set(self.NAME_TEMPLATE_DIRECTIVE, template_name)