Reputation: 33
I'm trying to add custom menu item in filter's dropdown list
in Odoo14 and owl framework some menu items exists in the base module inside the following snippet
<t t-name="web.CustomFilterItem" owl="1">
<div class="o_generator_menu">
<button type="button"
class="o_add_custom_filter dropdown-item"
aria-expanded="false"
t-ref="fallback-focus"
t-on-click="state.open = !state.open"
t-on-keydown="_onKeydown"
>
<t>Add Custom Filter</t>
</button>
</div>
</t>
So in my custom module am doing the following to add custom item
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-extend="web.CustomFilterItem">
<t t-jquery=".o_add_custom_filter" t-operation="after">
<div
role="separator"
class="dropdown-divider o_generator_menu"
/>
<button
type="button"
class="dropdown-item o_generator_menu o_add_advanced_search"
aria-expanded="false"
>Custom Item</button>
</t>
</t>
</templates>
But it doesn't appear. Any suggestions?
Upvotes: 0
Views: 2609
Reputation: 311
Odoo14 owl framework you can extend template using xpath.
you can use like this.
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="CustomFilterItem" t-inherit="web.CustomFilterItem" t-inherit-mode="extension" owl="1">
<xpath expr="//button[hasclass('o_add_custom_filter dropdown-item')]" position="before">
//your code
</xpath>
</templates>
Upvotes: 4