Ir al contenido
Menú
Se marcó esta pregunta
3168 Vistas

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


Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
3
sept 22
7159
1
ago 22
4704
3
mar 21
2021
5
feb 20
12001
2
feb 19
2802