【发布时间】:2019-04-11 15:17:43
【问题描述】:
我正在使用 Odoo 11,安装自定义模块时出现以下错误。这是一个在 Odoo 10 中工作的模块。我不知道哪里出错了。
Field `custom_discount_product_id2` does not exist
Error context:
View `pos.config.custom.discount.form.view`
[view_id: 1029, xml_id: pos_custom.view_pos_config_form_custom_discount, model: pos.config, parent_id: 730]
None" while parsing /odoo/custom/addons/pos_custom/views/pos_custom_sale_view.xml:22, near
<record model="ir.ui.view" id="view_pos_config_form_custom_discount">
<field name="name">pos.config.custom.discount.form.view</field>
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.pos_config_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@id='title']" position="after">
<group string="Custom Discount">
<field name="custom_discount_product_id2"/>
</group>
</xpath>
</field>
</record>
这是我的 sale.py 文件
from odoo import api, fields, models
class PosConfig(models.Model):
_inherit = 'pos.config'
custom_discount_product_id2 = fields.Many2one('product.product', string='Custom Discount Product')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
这是视图文件。
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="view_pos_config_form_custom_discount">
<field name="name">pos.config.custom.discount.form.view</field>
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.pos_config_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@id='title']" position="after">
<group string="Custom Discount">
<field name="custom_discount_product_id2" />
</group>
</xpath>
</field>
</record>
</data>
</openerp>
我检查了其他模块,重新启动了服务器,但由于某种原因没有创建该字段。
【问题讨论】:
-
from . import sale在models/__init__.py文件中吗?并且,from . import models在主要的__init__.py文件中吗?如果是这样,请重新加载模块并确保在日志中看到odoo.modules.registry: module <your_module>: creating or updating database tables -
是的。进口模型是问题所在。谢谢
-
太棒了!请您选择我的答案是否正确?
标签: odoo odoo-10 odoo-11 odoo-view