mercredi 6 novembre 2019

Show condition button in email template odoo 12

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

Aucun commentaire:

Enregistrer un commentaire