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

Selection Field, how does it work?

By
Michael Bos
on 9/3/14, 3:18 AM 818 views

I have been battling about with some selection fields and can't get them to work. Whenever I add them to my views it gives me XML erorr. So something must be wrong.

Does anybody has a guide for this?

Thank you

0
Niels Huylebroeck
On 9/11/14, 6:08 AM

Note with the new api you define a Selection field as follows:

from openerp import api, models, fields

class YourModel(models.Model):

_name = 'your.model'

my_selection_field = fields.Selection([('option1', 'Label 1'), ('option2', 'Label 2')], string='My Selection Field')

Using the new style gives the benefit of being able to extend the selection list by inheriting and redefining as follows:

my_selection_field = fields.Selection(selection_add=[('option3', 'Label 3')])

0

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 9/3/14, 3:22 AM

Maybe it is faster if you post your snippet.  In general you need these two part to create a selection field:

_columns = { 'my_selection_field': fields.selection([("code1", "Value 1"), ("code2", "Value 2")), string='My Selection Field')}

and include it in the view.

See this conversation: https://www.odoo.com/forum/help-1/question/odoo7-add-a-field-in-purchase-order-line-but-cant-save-61781

Ivan
on 9/3/14, 3:25 AM

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: 9/3/14, 3:18 AM
Seen: 818 times
Last updated: 4/9/15, 2:50 AM