Odoo Help


how can i assgin two different filters two same model but with different menu ?

Ahmed elbarbary
on 2/4/15, 4:21 AM 803 views

how to assign two different filters to same model ? such as products model in sales module (sales--->products) there is defined filter (can be sold ) and in purchase-->products there is defined filter can be purchase , now in warehouse --> products i need to define default filter but the problem is when i assign it it apply to all product views in sales and in purchase but i need it in warehouse only , how can i do that ? and how is it applied different filter to purchase and sales products ?

Thanks in advance


This can be done using the "window action". You can set the value of "context" under the action and achieve this.

Try to find the "action" for that menu and try to define your filter under the "context" attribute.

See the example

Product under Sales menu,

context = {"search_default_filter_to_sell":1} ---> this leads to default selection of "sellable" product filter.

context={"search_default_filter_to_purchase":1} ---> this leads to default selection of "purchase" product filter.

So here in the search view there is a filter already defined as "filter_to_sell" and "filter_to_purchase" and using this in the context value for different actions, appropriate filters are set as default selection during load of the list view.

For your reference in the product module search for "product_normal_action_sell" this action, you will get the idea.

So same way you need to define your filter and use the context attribute of the action.

Hope this helps !!.

thank you very much it is working, can i ask you another question ? is there away to assign defaults to fields when create product from warehouse menu which is different from defaults when create from sales menu ?

Ahmed elbarbary
on 2/4/15, 4:54 AM

thanks @ emipro technologies pvt ltd. this code fully work

Ankit H Gandhi(AHG)
on 2/4/15, 4:55 AM

Yes @elbarbary... it is possible to set default values for different action. You can do this by using {"default_field_name":>} in the context attribute. Try to look different actions, which are already there in the system, that will help you more.

Emipro Technologies Pvt. Ltd.
on 2/4/15, 5:23 AM

@ Emipro Technologies Pvt. Ltd. it is working fine thanks again for your help , i appreciate that

Ahmed elbarbary
on 2/4/15, 5:35 AM

@elbarbary ... You'r welcome...

Emipro Technologies Pvt. Ltd.
on 2/5/15, 8:26 AM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 2/4/15, 4:21 AM
Seen: 803 times
Last updated: 3/16/15, 8:10 AM