Skip to Content
Menu
This question has been flagged

Hello Community,Please help. I hava a problem when I create pdf report in qweb.....

I try this in myCustomize Modul and Report

<t t-set="i" t-value="1" />

<t t-foreach="request.env['x_surat_usul'].search([])" t-as="obj">

    <tr t-foreach="obj.x_pengajuan_materiil" t-as="a">

        <td class="text-center"><span t-esc="i"/><t t-set="i" t-value="i+1"/> </td>

        <td><span t-field="a.x_komponen" /></td>

        <td><span t-field="a.x_jum_ang_approve" /></td>

    </tr>

</t>

Then show

No   Category      Amount

1       Fasilitas             3

2       Fasilitas             2

3       Rumdin              2


And I want showing

No   Category      Amount

1       Fasilitas             5

2       Rumdin              2


Thanks ...


Avatar
Discard
Best Answer

Hi Sasmita,

As Sehrish said, you should create a parser of the report and then call a method in parser from xml.

Ex:

def get_rec(self, rec):
    vals = {}
    for cat in rec.x_pengajuan_materiil:
        if cat.x_komponen.name in vals:
            vals[cat.x_komponen.name] += cat.x_jum_ang_approve
        else:
            vals.update({cat.x_komponen.name: cat.x_jum_ang_approve})
    return vals

XML:

<!-- Save method value in variable -->
<t t-set="recs" t-value="get_rec(obj)"/>
<tr t-foreach="recs.keys()" t-as="a">
<!-- Print category name -->
    <span t-esc="a"/>
<!-- Print category amount -->
    <span t-esc="recs[a]" />
</tr>
Avatar
Discard
Best Answer

I will suggest you to handle data in report parser (using python logic instead of XML), check this how to create custom report using parser: http://learnopenerp.blogspot.com/2016/09/how-to-create-custom-reports-in-odoo.html

Avatar
Discard
Author Best Answer

Thanks for the answer. But I get error in your query sudhir  :)

do you have any solution ??

Avatar
Discard
Related Posts Replies Views Activity
1
Jul 18
9714
4
Nov 20
6270
4
Mar 20
16038
3
Aug 19
8775
3
May 18
6329