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.

0

Add custom filter in odoo v9 community

By
barbara
on 8/5/16, 7:06 AM 247 views

Hi everybody!

I would like to add a custom filter and always be displayed in the filter menu, could it be?

Thanks.

1

Ermin Trevisan

--Ermin Trevisan--
3546
| 6 3 7
Walchwil, Switzerland
--Ermin Trevisan--


Ermin Trevisan
On 8/5/16, 8:21 AM

You can save a filter, make it default and share it with all users:


The defined filter remains in the filter menu (with the filter definition) and is available under favorites with the saved name:



If you want to do this programmatically, here is an interesting post:

http://107.167.187.43/index.php/topics/view/searching-grouping

0
barbara
On 8/5/16, 8:26 AM

But there is no option to appear in the filter menu and not on the favorites?

See my amended answer.

Ermin Trevisan
on 8/5/16, 8:36 AM
0
Payam
On 8/5/16, 10:49 PM

If you meant have particular custom filter to the default filter list, you need to modify view

let's assume you want to have a custom filter for "Sale Price" over 10

first, you need to find the field name. activate the developer mode (i.e. help, about, activate developer mode)

edit a product

move the mouse over "Sale Price" and you will find the field name: "list_price"

Also, you would find that the object is "product.template"

then go to the setting, section (top bar) and select Technical->User Interface->Views

there search for views based on their object. i.e. put product.template in the search box and select the second item in the search box which searches over "objects"
then you will find that from "search" views, "product.template.search" would be the main view and others have been inherited from that

open it

and add this:

                    <filter string="over10" name="over_10" domain="[('list_price','>=',10)]"/>

save, go to any product search page (as you have modified the main search view) and you will see "over10" in the list of predefined filters

0
shameem@aχoncoms
On 8/5/16, 11:02 PM

Add filter in the search view and set context "search_default"+"name of filter" to 1.

Eg:

<filter string="Active" domain="[('account_type','=','normal')]" name="name_of_active"/>

Add context in action

<field name="context">{'search_default_name_of_active':1}</field>


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

1 follower(s)

Stats

Asked: 8/5/16, 7:06 AM
Seen: 247 times
Last updated: 8/8/16, 8:17 AM