Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
3 Antworten
2166 Ansichten

Is it possible to have Search More appear in dropdowns when there are only a few items?


Thanks.

Avatar
Verwerfen

Here's an example of how to use it:
<field name="partner_id" options="{'limit': 5}"/>

Beste Antwort

Hey Kent,


I hope you're doing well.


Yes, it's possible to enable the "Search More" option in drop-downs even when there are only a few items. You can achieve this using the OCA module called 'web_m2x_options', which is available for Odoo version 16. This module allows you to set a limit for the number of items displayed in the dropdown. If the number of records exceeds this limit, the "Search More" button will appear, allowing users to search for additional items.


Here's an example of how to use it:

Code is added in comment .


This code sets a limit of 5 for the number of items displayed in the dropdown for the field 'partner_id'. If there are more than 5 records available, the "Search More" button will be shown, allowing users to search for additional partners.


Hope this will help you.

Thanks & Regards,

Email:   odoo@aktivsoftware.com           

Skype: kalpeshmaheshwari

Avatar
Verwerfen
Beste Antwort

Thanks!

Avatar
Verwerfen
Beste Antwort

Hi Kent,

In Odoo, the "Search More" option typically appears in dropdowns when the number of records exceeds a certain threshold, which is configurable. However, by default, Odoo doesn't display "Search More" when there are only a few items in the dropdown.

If you want to customize this behavior to always show "Search More," regardless of the number of items in the dropdown, you would need to override the relevant views/templates in your custom module.
Here's a general approach to achieve this:

    Identify the view/template responsible for rendering the dropdown field you want to modify.
    Override that view/template in your custom module.
    Modify the overridden view/template to include the "Search More" option unconditionally.

For example,
        <record id="view_name_inherited" model="ir.ui.view">
            <field name="name">model_name.form_view_inherited</field>
            <field name="model">model.name</field>
            <field name="inherit_id" ref="module_name.view_name"/>
            <field name="arch" type="xml">
                <!-- Add the 'search_more' attribute to the field -->
                <xpath expr="//field[@name='drop_down_field']" position="attributes">
                    <attribute name="search_more">1</attribute>
                </xpath>
            </field>
        </record>

By adding the search_more="1" attribute to the <field> tag, you're instructing Odoo to always show "Search More" for that dropdown field, regardless of the number of items.


Hope this helps.


Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Dez. 19
2175
3
Aug. 24
19381
1
März 24
1316
5
März 22
15296
2
Mai 20
4173