当我尝试运行以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>
在openerp 7中工作正常,但在odoo 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
答案 0 :(得分:1)
由于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)}