I created a custom odoo module and now I want to make a search filter that makes it easy to search multiple fields at the same time. I added this code to my xml and I am able to search each field individually but would like to group them into one string so the user can search all the fields (mfr name 1-6) with one search. Does anybody know if this is possible?
<record id="product_template_search_custom_view" model="ir.ui.view">
<field name="name">product.template.customsearch</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_search_view"/>
<field name="arch" type="xml">
<xpath expr="/search/field[@name='name']" position="before">
<field name="x_mfrname1" string="Mfr Name1"/>
<field name="x_mfrname2" string="Mfr Name2"/>
<field name="x_mfrname3" string="Mfr Name3"/>
<field name="x_mfrname4" string="Mfr Name4"/>
<field name="x_mfrname5" string="Mfr Name5"/>
<field name="x_mfrname6" string="Mfr Name6"/>
</xpath>
</field>
</record>
You can use the filter_domain
attribute
<record id="product_template_search_custom_view" model="ir.ui.view">
<field name="name">product.template.customsearch</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_search_view"/>
<field name="arch" type="xml">
<field name="name" position="replace">
<field name="name" filter_domain="['|', '|', '|', '|', '|', ('x_mfrname1','ilike',self), ('x_mfrname2','ilike',self), ('x_mfrname3','ilike',self), ('x_mfrname4','ilike',self), ('x_mfrname5','ilike',self), ('x_mfrname5','ilike',self)]" />
</field>
</field>
</record>
For further information check the Odoo Documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With