错误详细信息:字段`af`不存在

时间:2016-09-03 20:10:47

标签: python orm openerp odoo-8 odoo-9

我收到此错误2天。 我已阅读有关同一错误的任何链接,每次都没有效果。

我正在尝试简单的继承 这是我的employee.py文件

class Employee(models.Model):
    _inherit = 'hr.employee'
    _description = "Inherited modules"

    af = fields.Char(string="AF")

这是我的employee.xml文件

<openerp>
    <data>
        <record id="hr_employee_contact_form_view" model="ir.ui.view">
            <field name="name">hr.employee</field>
            <field name="model">hr.employee</field>
            <field name="inherit_id" ref="hr.view_employee_form" />
            <field name="arch" type="xml">
                <notebook position="inside">
                    <page string="Contact">
                        <group>
                            <field name="af"/>
                        </group>
                    </page>
                </notebook>
            </field>
        </record>

        <record model="ir.actions.act_window" id="employee_list_action">
            <field name="name">Contacts</field>
            <field name="res_model">hr.employee</field>
            <field name="view_mode">tree,form</field>
        </record>
        <menuitem id="configuration_menu" name="Configuration"
                  parent="main_ayda_project_menu"/>
        <menuitem id="contact_menu" name="Employee"
                  parent="configuration_menu"
                  action="employee_list_action"/>
    </data>
</openerp>

这是我的__openerp__.py文件

# -*- coding: utf-8 -*-
{
    'name': "Smart Gateway",

    'summary': """ Smart Gateway """,

    'description': """
        Long description of module's purpose
    """,

    'author': "My Company",
    'website': "http://www.yourcompany.com",

    'category': 'Uncategorized',
    'version': '0.1',

    'depends': ['base',
                'hr'],

    'data': [
        # 'security/ir.model.access.csv',
        # 'views/views.xml',
        'views/templates.xml',
        'views/contact_master/contact.xml',
        'views/employee.xml'
    ],
    # only loaded in demonstration mode
    'demo': [
        'demo/demo.xml',
    ],
}

这是我的__init__.py文件

from . import controllers
from . import models

我已经处理了依赖性,但仍然遇到此错误。

ParseError: "Invalid view definition

Error details:
Field `af` does not exist

Error context:
View `hr.employee`
[view_id: 1859, xml_id: n/a, model: hr.employee, parent_id: 352]
None" while parsing file:///C:/Odoo%209.0-20160127/server/openerp/addons/ayda_project/views/employee.xml:3, near
<record id="hr_employee_contact_form_view" model="ir.ui.view">
            <field name="name">hr.employee</field>
            <field name="model">hr.employee</field>
            <field name="inherit_id" ref="hr.view_employee_form"/>
            <field name="arch" type="xml">
                <notebook position="inside">
                    <page string="Contact">
                        <group>
                            <field name="af"/>
                        </group>
                    </page>
                </notebook>
            </field>
        </record>

2 个答案:

答案 0 :(得分:1)

将employee.py文件添加到同一目录中的__init__.py文件中。 如果它与其他.py文件位于同一目录中。

from . import controllers
from . import models
from . import employee

更新你的插件

答案 1 :(得分:0)

from . import employee添加到__init__.py文件夹中的models

models/__init__.py档案:

...
from . import employee