跳至內容
選單
此問題已被標幟
2 回覆
4930 瀏覽次數

I have some selection field such as: 

salutation = fields.Selection(

        [('Mr.','Mr.'),

         ('Mrs.','Mrs.'), 

         ('Ms.','Ms.')],

        string='Salutation')


Now I want to add demo data in a record for this field, but I can't find the right syntax. I've tried used eval, but without success. 


<record id="object0" model="my.model">

    <field name="salutation" eval="[('Mr.','Mr.')]"/>

</record>

 


Can anyone give me a hint?


頭像
捨棄
最佳答案

Hi,
You can simply set value for a selection field as follows.

<record id="object0" model="my.model">
<field name="salutation">Mr.</field>
</record

in your case both values are 'Mr.'. selection field always store the 1st element of the tuple. I hope it will help.
Regards

頭像
捨棄
作者 最佳答案

Thanks a lot! that was the right answer! 

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
12月 17
16955
0
4月 15
3982
1
3月 15
9530
1
12月 24
1615
0
6月 19
3814