author: @kawam tags:#odoo


You have to create your custom tree view in your custom module and then inherit the applicant’s view and then add attribute context="{'tree_view_ref': 'your_tree_view_id'}" in context (partner_id) field.

source How do I specify the tree view to use for the ‘search more’ popup of a many2one? | Odoo

New Tree View

<record id="view_product_product_tree" model="ir.ui.view">
    <field name="name">product.product.tree</field>
    <field name="model">product.product</field>
    <field eval="8" name="priority"/>
    <field name="arch" type="xml">
        <tree string="Product">
            <field name="name"/>
            <field name="default_code"/>
        </tree>
    </field>
</record>

Inherit the field and add tree_view_ref

<record id="inherit_sale_order_form_view" model="ir.ui.view">
    <field name="name">sale.order.form</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
        <field name="order_line" position="attributes">
            <attribute name="context">{'tree_view_ref': 'module_name.view_product_product_tree'}</attribute>
        </field>
    </field>
</record>

Replace 'module_name' with the actual name of your Odoo module. This change will ensure that the custom tree view will be used when clicking “Search More” on the product_id field in the sale.order form view. Please note that ‘order_line’ field is a One2many field which holds all the order line records and in each order line, there is a product_id field which will be affected by this change.