Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
3129 มุมมอง

Hi,

I try to use if else statements on a mailing. But istead of applying the line statement on the final mail its always displaying the line statements.


Source code of mailing

<div class="o_layout o_basic_theme" style="padding: 0px; margin: 0px; color: black; font-size: 14px; background-color: white; min-height: 100%; width: 94%; box-sizing: content-box; overflow: hidden;">
  <div class="oe_structure">
    <div class="o_mail_no_options">
      % if object.titulation.titulation == "firstname":
      <p style="margin: 0px; color: black; font-size: 13px;">
        Hallo ${object.firstname or object.name or ' '},
      </p>
      % else:
      <p style="margin: 0px; color: black; font-size: 13px;">
        Hallo ${object.firstname or object.name or ' '},
      </p>
      % endif
      <p style="margin: 0px; color: black; font-size: 13px;">
        <br>
      </p>
      <p style="margin: 0px; color: black; font-size: 13px;">
        <br>
      </p>
      <p style="margin: 0px; color: black; font-size: 13px;">
        <br>
        <a href="/unsubscribe_from_list" class="o_default_snippet_text">Abmelden</a>
      </p>
    </div>
  </div>
</div>
result looks like this:
% if object.titulation.titulation == "firstname":

Hallo Christian,

% else:

Hallo Christian,

% endif


I am using the same code on a regular email template and everything works fine there.


อวตาร
ละทิ้ง

Well, you can try below code and it may resolve your error and you can get what you are looking for.

<div class="o_layout o_basic_theme" style="padding: 0px; margin: 0px; color: black; font-size: 14px; background-color: white; min-height: 100%; width: 94%; box-sizing: content-box; overflow: hidden;">
<div class="oe_structure">
<div class="o_mail_no_options">
{% if object.titulation.titulation == "firstname" %}
<p style="margin: 0px; color: black; font-size: 13px;">
Hello {{ object.firstname or object.name or ' ' }},
</p>
{% else %}
<p style="margin: 0px; color: black; font-size: 13px;">
Hello {{ object.firstname or object.name or ' ' }},
</p>
{% endif %}
<p style="margin: 0px; color: black; font-size: 13px;">
<br>
</p>
<p style="margin: 0px; color: black; font-size: 13px;">
<br>
</p>
<p style="margin: 0px; color: black; font-size: 13px ;">
<br>
<a href="/unsubscribe_from_list" class="o_default_snippet_text">Unsubscribe</a>
</p>
</div>
</div>
</div>

Thanks

คำตอบที่ดีที่สุด

Thanks for the reply from the Mabbly team. We have been looking for a solution to this problem for a long time

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Please make sure that %... begins on the first column of the code line.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi

I have exactly the same question. Were you able to solve this issue ?

Thanks.

อวตาร
ละทิ้ง

Hi
I finally found the solution.
I'm using this syntax and it works quite nicely:

${('<h1>Bienvenue</h1>' if object.lang=='fr_FR')}
${('<h1>Welkom</h1>' if object.lang=='nl_BE')}
${('<h1>Welcome</h1>' if object.lang=='en_US')}

@Ermin Trevisan : Starting the line with % in the code does not work because Odoo reformats the code when you switch to the wysiwyg view (indentation). And it even encapsulates the %if statement in a <p> element.

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ก.ค. 25
917
0
พ.ค. 22
2152
0
พ.ค. 21
1616
2
ก.ค. 16
5105
0
มี.ค. 15
3136