0

i have a question related to default search views.

Suppose i need to dynamically enable or disable a default filters how could i do? I tried this but it's not working:

<field name="context">
{
'search_default_not_closed':1,
'search_default_lancement':[('defaultLancement','=', True)]
}
</field>

Thanks

atacraft
  • 25
  • 1
  • 7

2 Answers2

0

The filter in odoo not like that Can you put all the code because the default filter like this

<record id="action_..." model="ir.actions.act_window">
    <field name="name">STAT</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">sale.report</field>
    <field name="view_type">form</field>
    <field name="view_id" ref="sale.view_order_product_tree"/>
    <field name="view_mode">tree</field>
    <field name="domain">[]</field>  
    <field name="context">{'search_default_Product':1}</field>
</record>

This simple example in < context > {'search_default_Product':1} the default is product

Boubaker
  • 427
  • 1
  • 7
  • 24
0

Found workaround ... changing the computed field i was searching on solved the endless loop issue (i was computing value of the same field i was searching on). fell free to improve. So ...

  • my search view has a field looks like

  • my menu context

    { 'search_default_not_closed':1, 'search_default_watingFor': 'Oui' }

  • my model

    watingFor = fields.Char(string="En attente de", compute="setWaitingForField", search="searchInWaitingFor") // duplicated and stored just to search on filterUsingWatingFor = fields.Char(string="En attente de", compute="setfilterUsingWatingFor", store=True)

    def searchInWaitingFor(self, operator, value): value = self.getUserGroupName() return [('filterUsingWatingFor', operator, value)]

atacraft
  • 25
  • 1
  • 7