【发布时间】:2018-02-12 15:49:12
【问题描述】:
我想遍历所有销售订单行并将每个产品的product_uom_qty 乘以product_id.weight,然后将所有值相加得到销售订单的总重量。
我在销售订单模板中看到过这样的构造:
<t t-set="display_discount" t-value="any([l.discount for l in doc.order_line])"/>
哪一个等效于在所有行上执行这种聚合乘法?
【问题讨论】:
我想遍历所有销售订单行并将每个产品的product_uom_qty 乘以product_id.weight,然后将所有值相加得到销售订单的总重量。
我在销售订单模板中看到过这样的构造:
<t t-set="display_discount" t-value="any([l.discount for l in doc.order_line])"/>
哪一个等效于在所有行上执行这种聚合乘法?
【问题讨论】:
你可以做类似的事情:
<t t-set="total_weight"
t-value="sum([l.product_uom_qty * l.product_id.weight for l in doc.order_line])" />
现在您可以“打印”变量total_weight。
【讨论】: