跳至內容
選單
此問題已被標幟
4 回覆
12996 瀏覽次數

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

頭像
捨棄

Try this,

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

作者

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

作者 最佳答案

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

 

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
10月 24
1088
0
8月 23
2464
1
12月 22
2189
0
7月 21
2521
1
4月 25
1017