Odoo Help


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.


odoo 8 dynamically enable and disable default filter

on 5/30/16, 11:12 AM 212 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)]

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)


Asked: 5/30/16, 11:12 AM
Seen: 212 times
Last updated: 6/1/16, 7:51 AM