Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
4 Risposte
12975 Visualizzazioni

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
Abbandona

Try this,

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

Autore

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

Autore Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
ott 24
1086
0
ago 23
2452
1
dic 22
2183
0
lug 21
2496
1
apr 25
1007