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

Why is this Selection method not working?

By
Phillip
on 4/20/15, 10:28 AM 487 views

I am trying to define a selection method. I have created a method that outputs the exact values I need.

    list = [(2, 'John Smith'), (3, 'Jill Smith')]

If I use the following return statement 

    return [(2, 'John Smith'), (3, 'John Smith')]

EVERYTHING WORKS!!!! A perfectly displayed selection field.

When I use 

    return list

I dont get any errors however I get no selection values in my drop down.

CODE BELOW

###############################################

                    WORKS

###############################################

@api.model

def _selection_method(self):

    some stuff

    return [(2, 'John Smith'), (3, 'John Smith')]

############################################

                     FAILS

############################################

@api.model

def _selection_method(self):

some stuff

     list = [(2, 'John Smith'), (3, 'John Smith')]

return list

#############################################

This is my selection field

selected_object = fields.Selection('_selection_method', string="Some String")


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: 4/20/15, 10:28 AM
Seen: 487 times
Last updated: 4/20/15, 10:28 AM