Openerp 尝试在Odoo中运行mako模板时出现Jinja错误

Openerp 尝试在Odoo中运行mako模板时出现Jinja错误,openerp,jinja2,odoo-8,openerp-7,mako,Openerp,Jinja2,Odoo 8,Openerp 7,Mako,我在尝试运行以mako模板编写的报告时遇到此错误: Encountered unknown tag 'total_price'. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'. <class 'jinja2.exceptions.TemplateSyntaxError'>,Encountered un

我在尝试运行以mako模板编写的报告时遇到此错误:

Encountered unknown tag 'total_price'. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.

<class 'jinja2.exceptions.TemplateSyntaxError'>,Encountered unknown tag 'total_price'. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.,<traceback object at 0x02F2F490>
遇到未知标记“总价”。Jinja正在寻找以下标签:“endfor”或“else”。需要关闭的最里面的块是“for”。
,遇到未知标记“总价”。Jinja正在寻找以下标签:“endfor”或“else”。需要关闭的最里面的块是“for”。,
在开场白7中效果很好,但在奥多8中没有效果

                <% total_price = 0.0 %>
                %for line_container_ids in shipping.container_line_ids:
                    <%
                        total_price = line_container_ids.product_qty * line_container_ids.net_price
                        curr = line_container_ids.currency_id.name
                    %>
                % endfor

%对于shipping.container\u line\u ID中的line\u container\u ID:
%结束

自从Odoo V8以来,您需要更改使用的语法,而使用jinja2似乎很难做到这一点。下面是一个在Odoo V9中使用销售订单测试的示例:

% set total_price = []
% for line in object.order_line:
    % if total_price.append(line.price_subtotal)
    % endif
% endfor
${sum(total_price)}