Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
7263 Zobrazení

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

Avatar
Zrušit

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.

Autor

How to make a for loop in Jinja?

Nejlepší odpověď

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
3
bře 17
8417
1
úno 22
5944
1
úno 19
8591
1
pro 16
5666
1
lis 15
8575