Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
8125 Lượt xem

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 ...


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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>
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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

do you have any solution ??

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 18
11037
4
thg 11 20
6539
4
thg 3 20
17415
3
thg 8 19
9065
3
thg 5 18
7269