Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
30533 มุมมอง

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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')])

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มี.ค. 15
4169
1
เม.ย. 25
1213
Odoo 10 selection field แก้ไขแล้ว
2
ก.ย. 17
12683
1
พ.ค. 23
3263
2
มี.ค. 18
5144