我正在使用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>
我检查了其他模块,重新启动了服务器,但是由于某种原因未创建该字段。
答案 0 :(得分:0)
确保<your_module>/__init__.py
包含:
from . import models
并且该<your_module>/models/__init__.py
包含:
from . import sale