1
votes

I would like to iterate over all sale order lines and multiply product_uom_qty by product_id.weight for each product, then sum up all values to get the total weight of the sale order.

I have seen a construct like this in sale order template:

<t t-set="display_discount" t-value="any([l.discount for l in doc.order_line])"/>

Which would be the equivalent to perform such aggregated multiplication over all lines?

1

1 Answers

1
votes

You can do something similar:

<t t-set="total_weight"
    t-value="sum([l.product_uom_qty * l.product_id.weight for l in doc.order_line])" />

Now you can "print out" the variable total_weight.