Skip to Content
Menú
This question has been flagged
2 Respostes
6174 Vistes

How do you iterate fields in qweb reports? since I have two classes, I want customer_id to iterate base on the tree view created.

Models:

Class A:
    _name = 'module.a'

    module_id = fields.Many2one(string='sale', comodel_name='sale.order')
    customer_id = fields.Many2one('res.partner', string="Customer Name")

Class B:
    _inherit = 'sale.order'
    module_ids = fields.One2many(string="Module B",
                    comodel_name='module.a', inverse_name='module_id')

xml template:

   <template id="module_template" inherit_id="sale.sale_order_portal_content">
     <xpath expr="//div[2]/section[1]" position="before">
        <section class="mt-5">
            <h3 class="">Customer</h3>
            <div t-foreach="module_ids" t-as="line">
                <span t-esc="line.customer_id"/>
            </div>
        </section>
     </xpath>
  </template>

I try to do this but it won't iterate the customer_id in qweb report. The thing that only shows is the h3 - "Customer".

Note: I need this One2Many and ManytoOne to be able to create an editable tree view that adds a customer.

Avatar
Descartar
Best Answer

Hello, William Draper

 

Try to access this,

<div t-foreach="sale_order.module_ids" t-as="line">

    <span t-esc="line.customer_id"/>

</div>

You have access the field in the report level with it's object ['sale_order'].

Thanks

Avatar
Descartar
Best Answer

Hi,

Please Check this,

https://www.odoo.com/documentation/12.0/reference/qweb.html

https://www.odoo.com/forum/help-1/question/how-to-print-a-one2many-field-values-in-qweb-report-in-odoo12-community-144726


Aswini iWesabe

Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
d’abr. 23
8466
3
de set. 20
4416
0
de gen. 25
1083
0
d’ag. 24
1608
1
de des. 23
2501