Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
10458 Visualizzazioni

I have many filter in place, created trough some xml migrated from V8 but on Odoo10 are not applied.

Example:

<record id= "Pos_orders_filter_view" model= "ir.ui.view">
 <field name= "name">Pos_orders_filter</field>
  <field name= "model">pos.order</field>
  <field name="type">search</field>
  <field name="inherit_id" ref="point_of_sale.view_pos_order_filter"/>
  <field name= "arch" type= "xml">
  <xpath expr="/search/filter[1]" position="before">
  <filter string= "Today" name= "Today" domain = "[['date_order','>=',datetime.datetime.now().strftime('%d-%m-%Y 00:00:00')]]"/>
  </xpath>
</field>
</record>
 
<record id= "pos_order_today" model= "ir.actions.act_window">
 <field name= "name">Today Order</field>
  <field name= "type">ir.actions.act_window</field>
  <field name= "res_model">pos.order</field>
  <field name= "view_type">form</field>
  <field name= "view_mode">tree</field>
  <field name= "context">{"Today":1}</field>
</record>

All the filters are in place in the respective model, but no one are set as default as should be.

I know I could simply set via front end but sometime when you deploy for a customer is hard to remember all you need to do.

Solved editing the 'context' field with:

<field name= "context">{"search_default_Today":1}</field>
Avatar
Abbandona
Risposta migliore

Hi,

Syntax not changed.  Since you defined a new action, I hope you don't want to modify the existing action to add a default search filter. So you may add this small change on your action to have that default search filter:

<record id= "pos_order_today" model= "ir.actions.act_window">
    <field name= "name">Today Order</field>
    <field name= "type">ir.actions.act_window</field>
    <field name= "res_model">pos.order</field>
    <field name= "view_type">form</field>
    <field name= "view_mode">tree</field>     
    <field name= "context">{"search_default_Today":1}</field>
</record>
Avatar
Abbandona
Autore

Completely miss the 'search_default_' prefix, present on V8 too. Thanks. But why it didn't rise an error or a warning in log?

Since I'm inheriting the pos_order view with new fields and new functions yes, I need to inherit the filters too adding 4 more.

And by the way your solution works fine on custom modules, but doesn't apply to an existing list of filters like point_of_sale.view_pos_order_filter. You need to choose the filter manually from the list and appy it trough front end.

It won't work, since there is no "name" attribute defined for those existing filters. So if you just inherit that filter and add the name attribute. Then you can override "point_of_sale.action_pos_pos_form" action and pass the search_default_filter context as usual, it will work on the existing filters.

Autore

Understood. Didn't think on that.

Post correlati Risposte Visualizzazioni Attività
0
set 17
4110
2
dic 22
16351
1
apr 20
142
1
giu 19
4278
1
set 18
106