Contributors mailing list archives

contributors@odoo-community.org

Browse archives

Avatar

QWeb widget templates - unable to use extension inheritance mode?

by
Data Dance s.r.o., Radovan Skolnik
- 06/08/2020 11:22:45

Hello,

 

I am working on a module that would allow to assgin icons to website menus to be rendered in custom theme. This is what I achieved:

 

Everything works as expected but I stumbled to template inheritance issue on the first widget - that is template: 'website.contentMenu.dialog.edit' defined in /addons/website/static/src/xml/website.contentMenu.xml For individual menu items it uses recursively template 'website.contentMenu.dialog.submenu' that has no JavaScript object associated. Now I wanted to use extension inheritance to alter content of this sub-template to render image/icon. So my aim was to use something like this:

 

<t t-inherit="website.contentMenu.dialog.submenu" t-inherit-mode="extension">

<xpath expr="//span[hasclass('input-group-append')]" position="inside">

<button type="button" t-att-class="submenu.fields['image']" aria-label="Menu Image" title="Menu Image"/>

</xpath>

</t>

 

Now whetever I tried this didn't work for me. I also tried to use something similar on the main template which is used by my JavaScript object extended from original. Didn't work as well. If it took my template it would generate into HTML literally the content of outer <t> tag - so the HTML contained tags <xpath expr="..."> and so on.

 

I solved it temporarily but copying both templates into my own file and modified them. But I would love to make this more elegant and extend the templates in-place as stated in documentation. Has anyone some experience with this? In all of the source code of Odoo 13.0, 12.0 and 11.0 I didn't find a single use of this feature for a reference.

 

Thank you for any help. Best regards

 

Radovan Skolnik

Follow-Ups