Ayuda

1

Show condition button in email template odoo 12

Avatar
Pawan Kumar Sharma

Hello All,

I override the survey template. And I added the condition to show button according to if and else condition. This condition based on one selection field in survey management. But when I try to send email it shows me error following error "The content of the text doesn't contain '__URL__'. __URL__ is automatically converted into the special URL of the survey."

class InheritedSurvey(models.Model):
_inherit = 'survey.survey'

survey_type = fields.Selection([('inhouse', 'In House'),
('3rd_party', '3rd Party')], store=True, default='inhouse')

Email template if and else condition:

<record id="survey.email_template_survey" model="mail.template">
<field name="name">Survey: Send by email</field>
<field name="model_id" ref="model_survey_survey"/>
<field name="subject">${object.title}: Survey</field>
<field name="body_html" type="html">
<div style="margin: 0px; padding: 0px; font-size: 13px;">
<p style="margin: 0px; padding: 0px; font-size: 13px;">
Hello
<br/>
<br/>
We are conducting a survey, and your response would be appreciated.
% if object.survey_type == 'inhouse':
<div style="margin: 16px 0px 16px 0px;">
<a href="__URL__"
style="background-color: #875A7B; padding: 8px 16px 8px 16px; text-decoration: none; color: #fff; border-radius: 5px; font-size:13px;">
Start Survey
</a>
</div>
% else:
<div style="margin: 16px 0px 16px 0px;">
<a t-attf-href="'%s&%s' % (__URL__, 1231)"
style="background-color: #875A7B; padding: 8px 16px 8px 16px; text-decoration: none; color: #fff; border-radius: 5px; font-size:13px;">
Testtttttttttttttt Survey
</a>
</div>
Thanks for your participation!
</p>
</div>
</field>
<field name="auto_delete" eval="True"/>
<field name="user_signature" eval="False"/>
</record>

Thanks in advance

Avatar
Descartar
1 Respuesta
0
Best Answer

I'm not sure, but it looks like in the first conditional the __URL__ is treated more like an string. However in the %else parte of the conditional it seems to be used as a variable. Have you tried to do something like this:

<a t-attf-href="'__URL__&%s' % (1231)" 

Maybe in that part of the code the __URL__ variable just does not exist and so  __URL__ simply just doesn't show up at the end as part of the text content ...


Just an idea, :)

Avatar
Descartar