This question has been flagged

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

Avatar
Discard
Best Answer

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 !!.

Avatar
Discard
Author

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 ?

thanks @ emipro technologies pvt ltd. this code fully work

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.

Author

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

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

I'm trying to figure out how to do this too. Where do you enter that? Or do you build a completely new module just for this one function? Can I do it in the frontend somehow?