[FIX] web_editor, website: define specific dynamic snippet name
Since [1] when the Dynamic Snippet was first introduced, it also introduced a concept of "inherited" snippets. Specific snippets would all `t-call` the same template for their rendering. A mechanism was introduced to deduce the `data-snippet` from the caller template, but it stored the obtained value in the `t-called` template itself. Because of this if several "specific snippets" that used that template had to be rendered, they would all have the `data-snippet` value of the first one that got compiled. We could compile the snippet template into something having a dynamically obtained `data-snippet` value, but then that would be equivalent to just using a `t-attf-data-snippet`. All specific snippets already do set a `snippet_name` in the context because it needs to be added in the classes. This commit therefore adds a `t-att-data-snippet` attribute on the base template, and populates with that same value in `onBuilt` for stable versions. During forward ports across stable versions, each new caller must be patched as well - and all patches must be removed in master. [1]: https://github.com/odoo/odoo/pull/53175 task-2922635 closes odoo/odoo#115566 X-original-commit: 73d2c9f87bf9a1a792f4318325c2e52fc81db5f2 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com> Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
This commit is contained in:
@@ -59,7 +59,7 @@ class IrQWeb(models.AbstractModel):
|
||||
sub_call = el.get('t-call')
|
||||
if sub_call:
|
||||
el.set('t-options', f"{{'snippet-key': '{snippet_key}', 'snippet-sub-call-key': '{sub_call}'}}")
|
||||
# If it already has a data-snippet it is a saved snippet.
|
||||
# If it already has a data-snippet it is a saved or an inherited snippet.
|
||||
# Do not override it.
|
||||
elif 'data-snippet' not in el.attrib:
|
||||
el.attrib['data-snippet'] = snippet_key.split('.', 1)[-1]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<template id="website.s_dynamic_snippet_template">
|
||||
<section t-attf-class="#{snippet_name} #{snippet_classes} s_dynamic o_dynamic_empty pt32 pb32">
|
||||
<section t-attf-class="#{snippet_name} #{snippet_classes} s_dynamic o_dynamic_empty pt32 pb32" t-att-data-snippet="snippet_name">
|
||||
<div class="container o_not_editable">
|
||||
<div class="css_non_editable_mode_hidden">
|
||||
<div class="missing_option_warning alert alert-info rounded-0 fade show d-none d-print-none">
|
||||
|
||||
Reference in New Issue
Block a user