Hi,
Just testing email templates and trying to do a loop on purchase lines in the body.
Here’s the body of my template:
Test Purchase: ${record.rec_name} → Ok Working
${record.lines[0].product.rec_name} → Ok Working
Not working:
{% for line in ${record.lines} %}
${line.product.rec_name} - ${line.quantity} - ${line.unit.rec_name}
{% end %}
I’m getting this error:
Traceback (most recent call last):File “/home/mrichez/Workspace/tryton/issues/tryton_74_dev/trytond/trytond/wsgi.py”, line 96, in dispatch_requestreturn endpoint(request, **request.view_args)File “/home/mrichez/Workspace/tryton/issues/tryton_74_dev/trytond/trytond/protocols/dispatcher.py”, line 44, in rpcreturn methods.get(request.rpc_method, _dispatch)(~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^request, database_name, *request.rpc_params)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File “/home/mrichez/Workspace/tryton/issues/tryton_74_dev/trytond/trytond/wsgi.py”, line 76, in wrapperreturn func(request, *args, **kwargs)File “/home/mrichez/Workspace/tryton/issues/tryton_74_dev/trytond/trytond/protocols/wrappers.py”, line 206, in wrapperresult = func(request, pool, *args, **kwargs)File “/home/mrichez/Workspace/tryton/issues/tryton_74_dev/trytond/trytond/protocols/dispatcher.py”, line 221, in dispatchresult = rpc.result(meth(inst, *c_args, **c_kwargs))~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^File “/home/mrichez/Workspace/tryton/issues/tryton_74_dev/trytond/trytond/modules/party/ir.py”, line 47, in getreturn super().get(record)~~~~~~~~~~~^^^^^^^^File "/home/mrichez/Workspace/tryton/issues/tryton_74_dev/trytond/trytond/ir/email.py", line 447, in get.render())~~~~~~^^File “/genshi/core.py”, line 184, in renderreturn encode(generator, method=method, encoding=encoding, out=out)File “/genshi/output.py”, line 59, in encodereturn _encode(‘’.join(list(iterator)))~~~~^^^^^^^^^^File “/genshi/output.py”, line 581, in callfor event in stream:^^^^^^File “/genshi/core.py”, line 292, in _ensurefor event in stream:^^^^^^File “/genshi/template/base.py”, line 641, in _includefor event in stream:^^^^^^File “/genshi/template/base.py”, line 601, in _flattenresult = _eval_expr(data, ctxt, vars)File “/genshi/template/base.py”, line 290, in _eval_exprretval = expr.evaluate(ctxt)File “/genshi/template/eval.py”, line 160, in evaluatereturn eval(self.code, _globals, {‘data’: data})File “”, line 1, in <Expression ‘line.product.rec_name’>File “/genshi/template/eval.py”, line 294, in lookup_nameval = cls.undefined(name)File “/genshi/template/eval.py”, line 397, in undefinedraise UndefinedError(key, owner=owner)genshi.template.eval.UndefinedError: “line” not defined
Fault: “line” not defined
What is the correct syntax for a loop in template ?
What about this issue Migrate from OldTextTemplate to NewTextTemplate of Genshi (#9751) · Issues · Tryton / Tryton · GitLab ?