Search code examples
xmlodooodoo-12

How to add Product Filter in pos.order model in Odoo 12


i want to add a filter name "product" as exactly the default filter in product model. i have given a picture of the filter which i want[the filter which is in add custom filter]. any help will be appreciated.the filter which is in add custom filter


Solution

  • For adding a new custom filter you should inherit the search view of the action like below:

        <record id="pos_order_view_search_inherit_product_filter" model="ir.ui.view">
            <field name="name">pos.order.search.inherit.product.filter</field>
            <field name="model">pos.order</field>
            <field name="mode">primary</field>
            <field name="inherit_id" ref="view_pos_order_search"/>
            <field name="arch" type="xml">
                <xpath expr="//search" position="inside">
                    <field name="lines" string="Product" filter_domain="[('lines.product_id', 'ilike', self)]"/>
                </xpath>
            </field>
        </record>
    

    This will add the option to search by product name in the search bar.

    You can create a custom addon to do this, or just create a view from the backend (Settings/Technical/Views menu).