如何在QWEB报表中汇总行Odoo 13?

问题描述

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

Odoo Report

这是从库存拣选模型中得出的。

我能够添加一条跨度线

<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-foreach="lines" t-as="line"> <t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/> 在每一行中,将值添加到变量中。

<span t-esc="current_subtotal"/>

然后打印它。

$filter