Contributors mailing list archives

contributors@odoo-community.org

Browse archives

Avatar

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

by
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: https://www.odoo.com/documentation/13.0/reference/qweb.html#template-inheritance

 

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="root.id"><t t-esc="root.name"/></option>

</t>

</select>

<ul class="oe_menu_editor list-unstyled">

<t t-foreach="widget.menu.children" t-as="submenu">

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

</t>

</ul>

<div class="mt32">

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

Drag to the right to get a submenu

</small>

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

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

</a><br/>

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

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

</a>

</div>

</div>

 

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

 

Radovan

 

 

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, < radovan@skolnik.info [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: https://odoo-community.org/groups/contributors-15 [2]

> Post to: mailto: contributors@odoo-community.org [3]

> Unsubscribe: https://odoo-community.org/groups?unsubscribe [4]

>

>

> _______________________________________________

> Mailing-List: https://odoo-community.org/groups/contributors-15 [5]

> Post to: mailto:contributors@odoo-community.org

> Unsubscribe: https://odoo-community.org/groups?unsubscribe [6]

>

>

>

> [1] mailto:radovan@skolnik.info

> [2] https://odoo-community.org/groups/contributors-15

> [3] mailto:contributors@odoo-community.org

> [4] https://odoo-community.org/groups?unsubscribe

> [5] https://odoo-community.org/groups/contributors-15

> [6] https://odoo-community.org/groups?unsubscribe

 

 

Reference