电子邮件模板odoo 12中的显示条件按钮

时间:2019-11-07 05:22:33

标签: templates if-statement href odoo

我覆盖了调查模板。我根据if和else条件添加了条件显示按钮。此条件基于调查管理中的一个选择字段。但是,当我尝试发送电子邮件时,显示错误“错误”,提示我“文本内容不包含' URL '。 URL 被自动转换为该调查。”

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

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

电子邮件模板是否满足以下条件:

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

预先感谢

0 个答案:

没有答案