Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
3178 Представления

guys why am I getting this error?

Failed to render template  using values {'user': res.users(1,), 'object': res.partner(141,)}
this is the related code when I'm trying to do an automated action like sending an SMS when a new quotation is created!


def render_template(self, template, model, res_id):
    """Render the given template text, replace mako expressions ``${expr}``
       with the result of evaluating these expressions with
       an evaluation context containing:

            * ``user``: browse_record of the current user
            * ``object``: browse_record of the document record this sms is
                          related to
            * ``context``: the context passed to the sms composition wizard

       :param str template: the template text to render
       :param str model: model name of the document record this sms is related to.
       :param int res_id: id of document records those sms are related to.
    """
    template = mako_template_env.from_string(tools.ustr(template))
    user = self.env.user
    record = self.env[model].browse(res_id)

    variables = {
        'user': user
    }
    variables['object'] = record
    try:
        render_result = template.render(variables)
    except Exception:
        _logger.error("Failed to render template %r using values %r" % (template, variables))
        render_result = u""
    if render_result == u"False":
        render_result = u""

    return render_result


Аватар
Отменить
Related Posts Ответы Просмотры Активность
3
сент. 22
7161
1
авг. 22
4706
3
мар. 21
2022
5
февр. 20
12002
2
февр. 19
2802