[![在此处输入图片描述][1]][1]我在向odoo12的销售订单视图中添加新字段时遇到问题。我创建了一个新模块。我希望你能帮助我。在我的视图表单的代码下方
<odoo>
<record id="view_order_form_inherit" model="ir.ui.view">
<field name="name">sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml"></field>
<field name="payment_term_id" position="after">
<field name="additional_note"/>
</field>
</record>
</odoo>```
when i try to install the new module i have the following error:
File "src\lxml\etree.pyx", line 3557, in lxml.etree._Validator.assert_
AssertionError: Element odoo has extra content: record, line 3
[1]: https://i.stack.imgur.com/e1DOw.png
问题出在这一<field name="arch" type="xml"></field>
行:<field>
标签已关闭,并且您的additional_note
字段在其外部声明。
试试这个代码:
<odoo>
<record id="view_order_form_inherit" model="ir.ui.view">
<field name="name">sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<!-- Leave the 'arch' field open -->
<field name="arch" type="xml">
<!-- Put your custom field and its position inside the 'arch' field.
Use 'xpath' tag to create a more precise positioning -->
<xpath expr="//group/group/field[@name='payment_term_id']" position="after">
<field name="additional_note"/>
</xpath>
<!-- Now, close the 'arch' field -->
</field>
</record>
</odoo>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句