ParseError:“Erreur lors de la validation de la contrainte
Le champ
nameLab
n'existe pas
<field name="order_line" mode="tree,kanban">
<tree string="labs Order Lines" editable="bottom" >
<field name="nameLab" />
</tree>
</field>
class test1 (models.Model):
_name = "test1"
order_line = fields.One2many('test2', 'order_id', string='Order Lines', copy=True)
nameLab = fields.Many2one('a_model',related='order_line.namelab',string='name Lab', store=True)
class test2(models.Model):
_name = 'test2'
namelab=fields.Many2one(comodel_name='a_model',
required=True, ondelete='cascade',)
编辑:
整个观点
<record id="view_invoice_lab_form" model="ir.ui.view">
<field name="name">lab.invoice.form</field>
<field name="model">lab.invoice</field>
<field name="arch" type="xml">
<form string="Labs Invoices" class="o_sale_order">
<header>
</header>
<sheet>
<div class="oe_title">
<h1>
<field name="name" readonly="1"/>
</h1>
</div>
<group>
<group>
<field name="T1" />
</group>
<group>
<field name="T2" />
<field name="T3"/>
<field name="T4"/>
<!-- <field name="sequence"/>
<field name="name"/> -->
</group>
</group>
<notebook>
<page string="Order Lines">
<field name="order_line" mode="tree,kanban">
<tree string="labs Order Lines" editable="bottom" >
<field name="nameLab" />
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
@api.onchange('nameLab')
def onchange_nameLab(self):
if self.nameLab:
答案 0 :(得分:1)
test2
没有字段nameLab
,但它有一个字段namelab
(请参阅大写字母L)。
解释:
<tree string="labs Order Lines" editable="bottom" >
<field name="nameLab" />
</tree>
在这里,您要渲染test2
(One2many order_line
是One {2} test2
而不是test1
。