您如何迭代qweb报表中的字段?因为我有两个类,所以我希望customer_id基于创建的树视图进行迭代。
型号:
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 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>
我尝试执行此操作,但不会在qweb报告中迭代customer_id。仅显示的是h3-“客户”。
注意:我需要使用One2Many和ManytoOne来创建添加客户的树形视图。
威廉·德雷珀
尝试访问此,
<div t-foreach="sale_order.module_ids" t-as="line">
<span t-esc="line.customer_id"/>
</div>
您可以使用object
['sale_order
']进入报告级别的字段。
谢谢