Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
4 Odgovori
13033 Prikazi

I'm looking to change the following code, but I'm struggling to understand the "then" aspect of this "if" statement

${('' if object.partner_id and object.partner_id.email and object.partner_id.email==object.email else object.email|safe)}


What I want is:

If partner_id exists and partner_id.email exists

Use partner_id.email field (how do I do this??)

Else

Use object.email


Thanks

Avatar
Opusti

Try this,

${('' if object.partner_id and object.partner_id.email and object.partner_id.email==object.partner_id.email else object.email)}

Avtor

Did not work @Niyas.

Error without exception. Probably due do sending an email without computed recipients.

then just try this also,

${('' if object.partner_id and object.partner_id.email and object.partner_id.email==object.partner_id.email else object.email|safe)}

Avtor Best Answer

I figured it out. These fields use jinga. It is an inline if statement:

The general syntax is <do something> if <something is true> else <do somethingelse>.

http://jinja.pocoo.org/docs/2.9/templates/#if-expression


My final code

${(object.partner_id.email if object.partner_id and object.partner_id.email else object.email|safe)}

 

Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
0
okt. 24
1121
0
avg. 23
2490
1
dec. 22
2208
0
jul. 21
2564
1
apr. 25
1052