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.

0

How to load enumeration values.

By
Binyam Assefa
on 10/15/15, 7:12 AM 456 views

I want to load enumeration value from my model to selection field without storing it to the database.i know that i can specify the list of values in the selection field but this way is not working with domain filter.I want the selection field to be filtered based on some condition?

0
Michael Telahun
On 10/16/15, 2:25 AM

Instead of listing the values in the selection field you can supply them from a function. The function will return a list of values:

def get_my_list(self):
do something...
    return [('a', 'A'),('b', 'B')]
my_list = fields.Selection(selection=get_my_list)

However, if you really need to set a domain on this field using a selection might not be the best option. I don't know your use-case so I can't comment on it, except to say that filtering a selection field seems sub-optimal to me.

Thanks Michale the thing i want is to limit the enum values based on some business constraints and i did it using a model with many2one field but with this thing i have to store the values in a database may be if it is possible to get values from model without storing it in database.

Binyam Assefa
on 10/16/15, 3:48 AM
0

Pawan

--Pawan--
1267
| 4 3 5
Hyderabad, India
--Pawan--


Pawan
On 10/16/15, 1:52 AM

Binyam,

Your query is not clear, but as far as i got, you want to make selection field work as a many2one field.

For that i would suggest you to go in reverse manner, make many2one field look as a selection field.

You can take a many2one field, and simply add widget="selection" in its xml part.

hope it works for you..!    

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)

Stats

Asked: 10/15/15, 7:12 AM
Seen: 456 times
Last updated: 10/16/15, 2:31 AM