【发布时间】:2019-06-16 19:18:12
【问题描述】:
我正在尝试在模块上编写代码。
但我被困住了。它不起作用。
Python 代码
class PurchaseCurrency(models.Model):
_inherit = "purchase.order.line"
new_currency = fields.Float(string="Test")
我的 xml
<record id="new_currency_line" model="ir.ui.view">
<field name="name">purchase.order.form</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='order_line']/tree/field[@name='product_qty']" position="after">
<field name="new_currency"/>
</xpath>
</field>
</record>
和错误警告
ValueError: 字段 new_currency 不存在
错误上下文:
查看purchase.order.form
[view_id:1074,xml_id:purchase.purchase_order_form,型号:purchase.order,parent_id:n/a]
有人可以帮助我吗?
【问题讨论】:
-
你导入你的python文件并重启Odoo了吗?
-
我已经做到了
-
你能在这里添加你服务器日志的所有错误吗?也许还有另一个错误或日志会显示您可能没有看到的其他内容。
-
ValueError:字段
new_currency不存在错误上下文:查看purchase.order.form[view_id:1074,xml_id:purchase_order_form,型号:purchase.order,parent_id:n/a] -
您能否检查一下该字段是否在表 purchase_order_line 的数据库中?这真的很奇怪。我在提供的代码中没有看到错误。它必须在您尚未提供的代码中。