如何对 QWEB 报告(Odoo 13)中的行求和?

How to sum lines in a QWEB report (Odoo 13)?

我有一份报告,这就是我想要做的。

这是选股批处理模型

我能够添加跨度线所以

<span t-esc="move_operation.mapped('picking_id').display_name"/>

这给了我产品的名称,但我需要能够添加这些行。

我试过了

<t t-esc="sum(l.price_total for l in move_operation.mapped('picking_id') " />

但是一直没有成功。

一种方法就像在发票中一样: https://github.com/odoo/odoo/blob/d3a6afe51fc4b864368acbc40a86ac6974d328dd/addons/account/views/report_invoice.xml#L72

你初始化了一个变量。

<t t-set="current_subtotal" t-value="0"/> 在每一行上,您都将值添加到变量中。

 <t t-foreach="lines" t-as="line">
     <t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/>

然后打印出来。

<span t-esc="current_subtotal"/>