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


I build a model from scratch and I need to build a report for only some fields.

The problem is that each job(field i called it : name) from my model has many debits in the 'account.move.line' model, however it is not a (many2one or one2many relation), I have checked that a list resulted from a method in my model is having what I am looking for, however I have a problem in displaying it in the qweb fromat, so I decided to insert this list in a new field in my model called debitx, but nothing change.

here is my method code:

 @api.multi
def _get_debit(self):

       total_len = self.env['account.move.line'].search([('analytic_account_id', '=', self.name)])
       l = []

       for item in total_len:
           item=item['debit']

           l.append(item)

       records = self.env['transfer.jobs']

       for i in l:
           records.write({'debitx':i})

the _get_debit method is inside my new (compute) field called debitx, this method is a member of my manage.job model.


and her is my report :

<?xml version="1.0"?>

<odoo> <report id="action_library_book_report"
string="JOBS REPORT"
model="transfer.jobs" report_type="qweb-pdf"
name="job_management.report_library_book_template" />



<template id="report_library_book_template">
<t t-call="web.html_container">
<t t-call="web.external_layout">
<div class="page">

<!-- Report header content -->
<div class="container">
<div class="row bg-primary">
<div class="col-3">JOB NO.</div>
<div class="col-2">Customer</div>

<div class="col-2">Debit</div>
<div class="col-2">Credit</div>
<div class="col-2">Balance</div>




</div>

<t t-foreach="docs" t-as="line">

<div class="row">
<!-- Report Row Content -->
<div class="col-3">
<h4><span t-field="line.name" /></h4>
</div>
<div class="col-2">
<span t-field="line.customer" />
</div>

<div class="col-2">
<span t-field="line.debitx"/>

</div>






<div class="col-2">
<!-- Render Authors -->
</div>
</div>


</t>
<!-- Report footer content ...-->
</div>


<t t-foreach="docs" t-as="o">
<!-- Report row content -->
</t>
<!-- Report footer content -->
</div>
</t>
</t>
</template>


</odoo>


Any suggestions, or how to create a qweb report from only lists returned by methods.

아바타
취소
베스트 답변

Hello,

Which transfer jobs are you writing it to?

When you are printing a transfer jobs report you are printing a record with a specific id, here to what specific record are you trying to write it.


Lets say you are printing a record with id 29 - you have to have a debix field written to a record with id 29.


Also the debitx value is being overwritten, it will have the last value in the loop. If you want to have all the values in the loop, use something like join.


",".join(l)

The above will join the l value to a string separated by a comma - you can use this considering you are using debitx as a text or a char field.

records = self.env['transfer.jobs']

       for i in l:
           records.write({'debitx':i})
아바타
취소
관련 게시물 답글 화면 활동
2
11월 19
8704
1
1월 20
5338
1
11월 19
6065
2
12월 18
4534
5
11월 18
8201