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

Hi,

how can i add a dropdown list in xml file 

i use odoo 8

thanks

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด
x = fields.Many2one(model_name, string)

In view

<field name="x"/>

This will give the dropdown on view with create and edit option of the related model and display the rec_name of each entries. If you need the pure selection list as a widget selection with the field.

<field name="x" widget="selection"/>


These are the params we use while creating many2one field.

 
  • comodel_name -- name of the target model (string)
  • inverse_name -- name of the inverse Many2one field in comodel_name (string)
  • domain -- an optional domain to set on candidate values on the client side (domain or string)
  • context -- an optional context to use on the client side when handling that field (dictionary)
  • auto_join -- whether JOINs are generated upon search through that field (boolean, by default False)
  • limit -- optional limit to use upon read (integer)

Next is you can use the Selection.

here you can specify values directly as a key value pair.

x = fields.Selection([
('normal', 'In Progress'),
('done', 'Ready for next stage'),
('blocked', 'Blocked')], string='State')










อวตาร
ละทิ้ง
ผู้เขียน

Hi,

thanks for your answer, i use windows 7 machine, were can i write this ?

in your models file

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
พ.ค. 23
1504
Button in Odoo แก้ไขแล้ว
2
ม.ค. 20
5624
1
ธ.ค. 16
3990
1
ธ.ค. 15
5739
3
ต.ค. 15
18470