Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

3

How to add custom filter?

By
Fransis L. Yoas
on 7/19/13, 8:03 AM 11,348 views

I add a new field using selection that consist list of country. How to filter the country in list view (using search field in top right of the screen)? Or how to add a search like "Search 'my_filter' for : " in the search bar like the image below? image description

5
mike
On 7/19/13, 9:33 AM

A good way to accomplish this is to modify that particular view, specifically the search view section. If it doesn't have one you can add it. Here is good instruction for this: link text

Also see this about the filter tag as another possible solution: link text

<filter string="Current" domain="[('state','in',('open','draft'))]" help="Draft, Open and Pending Tasks" icon="terp-project"/>
<field name="project_id" select="1" widget="selection">
    <filter domain="[('project_id.user_id','=',uid)]" help="My Projects" icon="terp-project"/>
</field>

The most simple method would be to create an advanced search including that custom field and save it.

Thanks for your answer, but can you help me to give a detailed step how to put that code or how to do it with developers mode in OpenERP? Because the documentation is not clear and I don't understand.

Fransis L. Yoas
on 7/19/13, 12:24 PM

with OpenERP in Developer Mode browse to the place where you want to change the view. Find the drop-down on the upper left and select Edit Search View. An Edit SearchView dialog will open with form fields for editing the name, type etc. as well as the code for the view. For examples of how to code this open the file addons\stock\stock_view.xml and find the record tag with ID = view_picking_internal_search. Now go into the Warehouse/Incoming Shipments section of the app and click on search. The code for the search items you see is in that view file. Should help you understand how it works.

mike
on 7/19/13, 1:25 PM

thank you for your answer..It's working..GBU

Fransis L. Yoas
on 7/22/13, 1:00 AM

Hi, You find a solution?

J.-M. Burri - Bureau ing.-conseils informatique, Anne-Sylvie Burri
on 10/29/13, 5:25 AM
2
Timo Talvitie
On 7/19/13, 1:18 PM
  1. Activate the Developer Mode

  2. Go to the view you want to add the filter to

  3. From the debug dropdown menu, select Manage Filters, and click Create

  4. Give the filter a name and select the correct model (in your case Project Issue?)

  5. Clear the User field so that everyone can access the filter

  6. In the Domain section you put the filter condition itself, for example [('region','=','Africa')]

  7. Save and go back to the tree view, and your filter should show up in the Custom Filters section of the search box

Hope that helps

Thanks for helping and giving answer. But it seems not working properly. I editing [('region','=','Africa')] into [('x_region','=','Africa')] (my field name) but it always get all of the issue. But if the code works, it still not a simple way to do with filter, isn't it? Because I have 7 selection of region, and if the user want to select 1 filter, he/she must have a 'anothor step to do' to pick the dropdown list in the search view. But again, thanks for your answer.

Fransis L. Yoas
on 7/20/13, 3:13 AM
0
Cidex
On 3/28/16, 5:15 PM

To search customers by phone or by mobile:

1. Activate the Developer Mode

2. Go to sales, customers

3. From the debug dropdown menu, select Edit SearchView

To search by phone add:

<field name="phone" filter_domain="['|','|',('display_name','ilike',self),('ref','=',self),('phone','ilike',self)]"/>

To search by mobile add:

<field name="mobile" filter_domain="['|','|',('display_name','ilike',self),('ref','=',self),('mobile','ilike',self)]"/>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 7/19/13, 8:03 AM
Seen: 11348 times
Last updated: 8/12/16, 5:21 AM