Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
7090 Lượt xem

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,)

Ảnh đại diện
Huỷ bỏ

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.

Tác giả

How to make a for loop in Jinja?

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 3 17
8322
1
thg 2 22
5810
1
thg 2 19
8505
1
thg 12 16
5559
1
thg 11 15
8471