Se rendre au contenu
Menu
Cette question a été signalée
3 Réponses
2182 Vues

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


Thanks.

Avatar
Ignorer

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

Meilleure réponse

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
Ignorer
Meilleure réponse

Thanks!

Avatar
Ignorer
Meilleure réponse

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
Ignorer
Publications associées Réponses Vues Activité
2
déc. 19
2175
3
août 24
19403
1
mars 24
1326
5
mars 22
15326
2
mai 20
4189