Skip to Content
Menu
This question has been flagged
1 Reply
4042 Views


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.

Avatar
Discard
Best Answer

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})
Avatar
Discard
Related Posts Replies Views Activity
2
Nov 19
7258
1
Jan 20
4078
1
Nov 19
5150
2
Dec 18
3203
5
Nov 18
6805