gpt4 book ai didi

python - 错误详细信息 : Field `af` does not exist

转载 作者:太空宇宙 更新时间:2023-11-03 16:11:01 25 4
gpt4 key购买 nike

我收到此错误已有 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>

最佳答案

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

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

更新您的插件

关于python - 错误详细信息 : Field `af` does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39310919/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com