Odoo Help


odoo 8 dynamically enable and disable default filter

on 5/30/16, 11:12 AM 645 views

Hello, 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_lancement':[('defaultLancement','=', True)]




On 6/1/16, 4:20 AM

I tried using a computed field as folowing:

watingFor = fields.Char(string="En attente de", compute="setWaitingForField", search="searchInWaitingFor")

my compute function works fine.

But i have an endless loop with my search function (this one is called indefinitely):

def searchInWaitingFor(self, operator, value):

    value = 'Lancement'

    return [('watingFor', operator, value)]

The main idea in the function above is:

- if i can change the value params depending on rules i will define then ...

- i can define a field in my search_view as following

<field name="watingFor" string="En attente du groupe Lancement"/>

- and i can enable default_filter on waitingFor field

{ 'search_default_watingFor': 1}

but as i said the search function is called again and again ... thanks for helping

######## I finally got a solution #########

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


<field name="watingFor" string="En attente de mon groupe"/>


- my menu context

<field name="context">



'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)]

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: 5/30/16, 11:12 AM
Seen: 645 times
Last updated: 6/1/16, 7:51 AM