Contributors mailing list archives

Browse archives


Re: QWeb widget templates - unable to use extension inheritance mode?

Data Dance s.r.o., Radovan Skolnik
- 06/08/2020 13:29:49

I am no expert as well so I may be missing something crucial. What you describe is deprecated mechanism that doesn't allow in-place extension of the template. I mean you cannot change existing template without assigning it a new name (at least as far as I know). For both there is nice documentation online:


Initially I tried to use that mechanism you mention as well. But there is this (marked in red) in main template:

<div t-name="website.contentMenu.dialog.edit">

<select class="form-control mb16" t-if="widget.roots">

<t t-foreach="widget.roots" t-as="root">

<option t-att-value=""><t t-esc=""/></option>



<ul class="oe_menu_editor list-unstyled">

<t t-foreach="" t-as="submenu">

<t t-call="website.contentMenu.dialog.submenu"/>



<div class="mt32">

<small class="float-right text-muted">

Drag to the right to get a submenu


<a href="#" class="js_add_menu">

<i class="fa fa-plus-circle"/> Add Menu Item


<a href="#" class="js_add_menu" data-type="mega">

<i class="fa fa-plus-circle"/> Add Mega Menu Item





That is call to sub-template that has no associated JS object. So if I extended that template it would have different name so I would need to modify this template to reflect that. Tried and failed. Didn't work.


Best regards





On štvrtok 6. augusta 2020 12:46:56 CEST Graeme Gellatly wrote:

> I never did it that way. I'm no expert but usually I use t-jquery

> t-operation t-extend style syntax. On Thu, 6 Aug 2020, 9:26 pm Radovan

> Skolnik, < [1] > wrote: 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

> _______________________________________________

> Mailing-List: [2]

> Post to: mailto: [3]

> Unsubscribe: [4]



> _______________________________________________

> Mailing-List: [5]

> Post to:

> Unsubscribe: [6]




> [1]

> [2]

> [3]

> [4]

> [5]

> [6]