Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
5528 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
2
Apr 23
7760
3
Sep 20
3877
0
Jan 25
549
0
Agu 24
912
1
Des 23
1758