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.

4

How can i use a field function in the domain filter?

By
Yug Faa
on 2/5/13, 10:09 AM 6,116 views

I have a field function named access_user that's returns boolean

When i use it in the domain it does't work :

[('access_user','=',True)]

Always all records are showon, even if access_user is False, , when i use an other type of field than function it works.

Any idea ?

Hi Yug i have the some problem can'i know how do you resolve it

kaisusr
on 11/27/14, 6:12 AM

@Nicolas bessi has answered this question bellow

Yug Faa
on 11/27/14, 9:14 AM

Thank you Mr, nbessi Can you tell me more, please ? I want to implement this, Thanks

Yug Faa
on 2/5/13, 10:36 AM
3

Nicolas Bessi

--Nicolas Bessi--
1590
| 5 7 8
Lausanne, Switzerland
--Nicolas Bessi--
Nicolas Bessi
On 2/5/13, 10:32 AM

Hello,

You can implement fnct_search optional argument of your function field if you do not want to store it.

Then you will be able to search and filter on it.

This is also useful if there is a faster way to search than comparing all the values or if your search must behave in a particular way.

Camptocamp SA
on 2/5/13, 10:36 AM
3

Yannick Vaucher

--Yannick Vaucher--
1699
| 5 7 9
Lausanne, Switzerland
--Yannick Vaucher--
Yannick Vaucher
On 2/5/13, 10:10 AM

You can use a function field in domain and searches if you defined this field as store=True or store={triggers} in your model.

Remember that without setting triggers, your value will be recomputed only if the record itself is modified, if the formulas is related on value of on some relations, this has to be triggered by triggers.

Reference: store parameter in v6.1 doc (also valid for v7)

EDIT: more info based on Guewen's comment

A precision: the value must be stored in the database (vs. computed) to be searchable. So, store should be True or use more precise triggers.

Camptocamp SA, Guewen Baconnier - Software Developer, Camptocamp
on 2/5/13, 10:18 AM
0
namiri
On 10/9/14, 3:19 AM

hi Yug Faa

i have the same problem do you resolve it ?

regrads
 

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

2 follower(s)

Stats

Asked: 2/5/13, 10:09 AM
Seen: 6116 times
Last updated: 3/16/15, 8:10 AM