コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
4925 ビュー

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
16954
0
4月 15
3979
1
3月 15
9525
1
12月 24
1610
0
6月 19
3812