我使用的是Odoo 12。我不能访问Odoo的Python部分,只能访问Odoo开发者模式。我安装了web_one2many_kanban模块,但是除了图像和我的one2many行的id之外,我不能显示其余的数据。
我的代码:
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_card {{ record.x_bom_line_ids.raw_value }}">
<t t-if="record.x_bom_line_ids.raw_value">
<div class="row">
<div class="col-8">
<strong>
<span>
<t t-esc="record.product_id.value"/>
</span>
</strong>
</div>
<div class="col-4">
<strong>
<span class="float-right text-right">
<t t-esc="record.x_virtual_available.value"/>
</span>
</strong>
</div>
</div>
</t>
</div>
</t>
<t t-foreach="record.x_bom_line_ids.raw_value" t-as="room">
<img t-att-src="kanban_image('mrp.bom.line', 'x_image', room)" t-att-data-member_id="room" />我的错误:
"Uncaught TypeError: Cannot read property 'value' of undefined"发布于 2019-03-13 22:58:23
您忘了提及要为其编写此模板的记录的模型。从您的代码中可以明显看出,您正在尝试显示两个关系字段的value字段,一个是product_id,另一个是x_virtual_available。出现给定的错误消息是因为,您的记录的任何一个相关字段都未设置,因此python的值为False/empty,javascript的值为undefined。当您尝试访问该相关字段的值字段时,您会收到此错误。要解决此错误,请仔细查看您的记录并检查这些字段的值。
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_card {{ record.x_bom_line_ids.raw_value }}">
<t t-if="record.x_bom_line_ids.raw_value">
<div class="row">
<div class="col-8">
<strong>
<span>
<t t-esc="record.product_id.name"/>
</span>
</strong>
</div>
<div class="col-4">
<strong>
<span class="float-right text-right">
<t t-esc="record.x_virtual_available"/>
</span>
</strong>
</div>
</div>
</t>
</div>
</t>
<t t-foreach="record.x_bom_line_ids.raw_value" t-as="room">
<img t-att-src="kanban_image('mrp.bom.line', 'x_image', room)" t-att-data-member_id="room" />发布于 2019-03-18 16:37:54
抱歉,我理解了这个错误,我关注的是字段many2many而不是one2many!问题解决了,但现在我尝试用另一个字段one2many做同样的事情,它不工作,第一部分工作,但第二部分不工作,为什么?
<p>
<t t-foreach="record.x_bomlineids.raw_value" t-as="r">
<span style="color:blue !important;">
<strong> <t t-esc="r.x_name" t-att-data-list_id="r"/></strong></span>
<span style="color:grey !important;"> Démixé libre: </span><strong>
<t t-esc="r.x_virtual_available" /> </strong><t t-esc="r.x_unite"/> <br/>
</t>
</p>
<p>
<t t-foreach="record.bom_line_ids.raw_value" t-as="l">
<span style="color:blue !important;">
<strong> <t t-esc="l.product_tmpl_id" t-att-data-list_id="l"/>
</strong></span>
<span style="color:grey !important;"> stock coli mixte: </span>
<strong><t t-esc="l.x_virtual_available" /> </strong><t t-esc="l.x_unite"/> <br/>
</t>
</p>https://stackoverflow.com/questions/55141706
复制相似问题