字段不存在 ODOO

Field does not exist ODOO

我正在使用 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>

我已经检查了其他模块,重新启动了服务器,但由于某种原因没有创建该字段。

确保 <your_module>/__init__.py 包含:

from . import models

并且 <your_module>/models/__init__.py 包含:

from . import sale