콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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


아바타
취소
베스트 답변

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>
아바타
취소
베스트 답변

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

아바타
취소
작성자 베스트 답변

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

do you have any solution ??

아바타
취소
관련 게시물 답글 화면 활동
1
7월 18
11081
4
11월 20
6568
4
3월 20
17472
3
8월 19
9100
3
5월 18
7309