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

How to open these 2 stock.picking action with 2 differents default filters?

By
Pascal Tremblay
on 4/6/15, 5:19 PM 944 views

Hello guys,

There is something I can't manage... Once again... Grrr. 

I have 2 different filters. I have 2 different actions. 

These 2 actions open the same model : stock.picking


Importation of filters :

<record id="stock_lapagept.all_delivery_orders_pt" model="ir.filters">

<field name="name">all_delivery_orders_pt</field>

<field name="model_id">stock.picking</field>

<field name="user_id" eval="False" />

<field name="domain">[['company_id', 'ilike', 'Page'], ['name', 'ilike', 'OUT']]</field>

<field name="context">{}</field>

<field name="is_default">False</field>

</record>

<record id="stock_lapagept.all_pos_orders_pt" model="ir.filters">

<field name="name">all_pos_orders_pt</field>

<field name="model_id">stock.picking</field>

<field name="user_id" eval="False" />

<field name="domain">[['company_id', 'ilike', 'Page'], ['name', 'ilike', 'PICKPOS']]</field>

<field name="context">{}</field>

<field name="is_default">False</field>

</record>


Filters are imported :



Importation of new actions :

<record id="stock.action_delivery_orders" model="ir.actions.act_window">

<field name="name">Delivery orders - PT action</field>

<field name="res_model">stock.picking</field>

<field name="type">ir.actions.act_window</field>

<field name="context">{'search_default_all_delivery_orders_pt': 1,'default_all_delivery_orders_pt': 1}</field>

</record>

<record id="stock.action_pos_orders" model="ir.actions.act_window">

<field name="name">Point of sale orders - PT action</field>

<field name="res_model">stock.picking</field>

<field name="type">ir.actions.act_window</field>  

<field name="context">{'search_default_all_pos_orders_pt': 1,'default_all_pos_orders_pt': 1}</field>

</record>



Here, it is always impossible to get the default filter in the search field at the top right (like on image below). If I click on Delivery orders - PT, I want to open WITH THE RIGHT FILTER : all_delivery_orders_pt




UPDATE #1

With this update, both filters get is_default to true in the Settings->Usder-defined filters. So, I always get the first one ('search_default_all_delivery_orders_pt') in the search field at the top right of my custom view. May be I should create 2 different search views? Don't forget, both filters are applied to the same model...


<record id="stock.action_delivery_orders" model="ir.actions.act_window">

<field name="name">Delivery orders - PT action</field>

<field name="res_model">stock.picking</field>

<field name="type">ir.actions.act_window</field>

<field name="context">{'search_default_all_delivery_orders_pt': True}</field>

<field name="search_view_id" ref="stock.view_picking_internal_search" />

</record>

<record id="stock.action_pos_orders" model="ir.actions.act_window">

<field name="name">Point of sale orders - PT action</field>

<field name="res_model">stock.picking</field>

<field name="type">ir.actions.act_window</field>

<field name="context">{'search_default_all_pos_orders_pt': True}</field>

<field name="search_view_id" ref="stock.view_picking_internal_search" />

</record>


 

may be I should use filter_domain in the search view...

Pascal Tremblay
on 4/6/15, 6:52 PM
1

Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--
4136
| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 4/6/15, 7:07 PM


<record id="stock.action_delivery_orders" model="ir.actions.act_window">

<field name="name">Delivery orders - PT action</field>

<field name="res_model">stock.picking</field>

<field name="type">ir.actions.act_window</field>

<field name="context">{'search_default_all_delivery_orders_pt': True}</field>

</record>


<record id="stock.action_pos_orders" model="ir.actions.act_window">

<field name="name">Point of sale orders - PT action</field>

<field name="res_model">stock.picking</field>

<field name="type">ir.actions.act_window</field>

<field name="context">{'search_default_all_pos_orders_pt': True}</field>

</record>


and add to your 2 actions:

<field name="search_view_id" ref="module_name.id_of_view_search"/>

should be but to verify:

<field name="search_view_id" ref="stock.view_picking_internal_search"/>

I updated my question. Still something missing. Thanks.

Pascal Tremblay
on 4/6/15, 8:35 PM
0

Pascal Tremblay

--Pascal Tremblay--
1312
| 5 2 7
Alma, Canada
--Pascal Tremblay--


Pascal Tremblay
On 4/6/15, 9:01 PM

Thanks a lot mister Gaspard.

I have found this post : https://www.odoo.com/fr_FR/forum/help-1/question/how-can-i-assgin-two-different-filters-two-same-model-but-with-different-menu-75272

Conclusion : I think we should create filters in the search view and NOT in ir.filters.

CODE :

<record id="stock.view_picking_internal_search" model="ir.ui.view">

<field name="name">stock.picking.internal.search</field>

<field name="model">stock.picking</field>

<field name="arch" type="xml">

<search string="Picking Lists">

<filter string="all_delivery_orders_pt" name="all_delivery_orders_pt" domain="[['company_id', 'ilike', 'Page'], ['name', 'ilike', 'OUT']]"/>

<filter string="all_receipts_pt" name="all_receipts_pt" domain="[['company_id', 'ilike', 'Page'], ['name', 'ilike', 'IN']]"/>

<filter string="all_internal_transfers_pt" name="all_internal_transfers_pt" domain="[['company_id', 'ilike', 'Page'], ['name', 'ilike', 'INT']]"/>

<filter string="all_pos_orders_pt" name="all_pos_orders_pt" domain="[['company_id', 'ilike', 'Page'], ['name', 'ilike', 'PICKPOS']]"/>

<filter string="all_dropship_pt" name="all_dropship_pt" domain="[['company_id', 'ilike', 'Page'], ['name', 'ilike', 'DS']]"/>

<field name="name" string="Picking List" filter_domain="['|',('name','ilike', self),('origin','ilike',self)]"/>

<filter icon="terp-check" name="draft" string="Draft" domain="[('state','=','draft')]" help="Draft Moves"/>

<filter icon="terp-check" name="available" string="Ready" domain="[('state','in',('assigned', 'partially_available'))]" help="Assigned Moves"/>

<filter icon="terp-check" name="waiting" string="Waiting Availability" domain="[('state','=', 'confirmed')]" help="Waiting Moves"/>

<filter icon="terp-camera_test" name="confirmed" string="Confirmed" domain="[('state','in', ('confirmed', 'waiting', 'assigned'))]" help="Confirmed Moves"/>

<filter icon="terp-dialog-close" name="done" string="Done" domain="[('state','=','done')]" help="Pickings already processed"/>

<separator/>

<filter name="late" string="Late" domain="[('min_date','<', time.strftime('%%Y-%%m-%%d %%H:%%M:%%S'))]" help="Pickings that are late on scheduled time"/>

<separator/>

<filter name="backorder" string="Backorders" domain="[('backorder_id','<>', False)]" help="Remaining parts of picking partially processed"/>

<field name="partner_id" filter_domain="[('partner_id','child_of',self)]"/>

<field name="product_id"/>

<field name="picking_type_id"/>

<field name="group_id"/>

<group expand="0" string="Group By">

<filter string="Status" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>

<filter string="Order Date" icon="terp-go-month" domain="[]" context="{'group_by':'date'}"/>

<filter string="Expected Date" icon="terp-go-month" domain="[]" context="{'group_by':'min_date'}"/>

<filter string="Origin" domain="[]" context="{'group_by':'origin'}"/>

<filter string="Picking Type" domain="[]" context="{'group_by':'picking_type_id'}"/>

<filter string="Procurement Group" domain="[]" context="{'group_by':'group_id'}"/>

</group>

</search>

</field>

</record>

Yes I think too, I never do ir_filter like you. for the rest, what I done should be good, bye

Cyril Gaspard (GEM)
on 4/7/15, 2:58 AM

you can keep same view, add just in context a value 'your_variable': True or False depending the case , and use it to display or not in search view your filter with attrs="{'invisible': [('your_variable': True)]}"

Cyril Gaspard (GEM)
on 4/7/15, 3:03 AM

Thanks for all

Pascal Tremblay
on 4/7/15, 9:25 AM

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: 4/6/15, 5:19 PM
Seen: 944 times
Last updated: 4/6/15, 9:19 PM