Odoo Help

1

How To group by product category in qweb report ?

By
MouBou
on 6/2/16, 12:24 PM 2,246 views

Hello Community ,I'm facing a probleme ,i want to create an invoice wich show the list of product sales grouped by category 

i tried this

<t t-foreach="o.order_line" t-as="l">

<t t-if="l.product_id.categ_id">

<tr>  <td>

<span t-field="l.product_id.categ_id"/>

</td> </tr> </t>


but dosen't groub all products it show this result:

category 1

product 1

category 1

product 2


i want this resulat 

category 1

product 1

product 2

etc ...

thanks in advance


5
Jusab Sida (jsi)
On 6/3/16, 8:50 AM

Here is the code for grouping...

<t t-set="product_category" t-value="[]"/>

<t t-foreach="o.order_line" t-as="l">

<t t-set="product_category" t-value="product_category+[l.product_id.categ_id]"/>

</t>

<t t-foreach="set(product_category)" t-as="category">

<div><strong t-esc="category.name"/></div>

<t t-foreach="o.order_line" t-as="l">

<t t-if="category.id==l.product_id.categ_id.id">

<div><span t-field="l.product_id"/></div>

</t>

</t>

</t>

Thanks so much Jusab. Big help.

Giezel Esteves
on 11/7/16, 9:58 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 6/2/16, 12:24 PM
Seen: 2246 times
Last updated: 9/21/16, 4:38 AM