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

i want to show values of many2many field by jinja 2,

intrested_in = fields.Many2many('intrested.property', string='Intrested In')

class intrestedProperty(models.Model):

    _name = 'intrested.property'

    _rec_name = 'intrested_in'

    intrested_in = fields.Char('Intrested In')

i write a code liike -

INTERESTED IN : ${object.intrested_in}  

Gives output :

INTERESTED IN : intrested.property(1,)

アバター
破棄

You need to loop over the records first before printing values. You're literally printing the object (so a record or recordset) instead of a field value.

著作者

How to make a for loop in Jinja?

最善の回答

Hi,

To display many2many field values in email templates using jinja you have to use the jinja loop check the below example in my example "message" contain a many2many object.

{% for item in message %}


<li>{{{ item.name }}}</li>


 {% endfor %}


here I displaying name field value of many2many object using jinja loop syntax

Regards

アバター
破棄
関連投稿 返信 ビュー 活動
3
3月 17
8413
1
2月 22
5941
1
2月 19
8589
1
12月 16
5665
1
11月 15
8571