OpenERP 7将字段添加到现有模块-XML验证错误 [英] OpenERP 7 Adding Field to Existing Module - XML Validate Error

查看:80
本文介绍了OpenERP 7将字段添加到现有模块-XML验证错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是刚开始编辑/编程OpenERP模块的人,所以我关注

I'm new to editing/programming OpenERP modules so I'm following this tutorial to simply add a field to the projects module. I've run into a few errors and I've fixed them all, but now my XML simply won't validate. I've read multiple forum posts, read every similar post here on stackoverflow and I can't figure out my problem. So, here's the server's error log output and my files:

openerp-server.log:

openerp-server.log:

2014-05-28 17:56:13,120 29680 ERROR mct openerp.osv.orm: Can't find field 'mct_projects_machine' in the following view parts composing the view of object model 'project.project':
 * project.project.form

Either you wrongly customized this view, or some modules bringing those views are not compatible with your current data model
2014-05-28 17:56:13,122 29680 ERROR mct openerp.addons.base.ir.ir_ui_view: Can't render view  for model: project.project
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/openerp/addons/base/ir/ir_ui_view.py", line 126, in _check_render_view
    fvg = self.pool.get(view.model).fields_view_get(cr, uid, view_id=view.id, view_type=view.type, context=context)
  File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 2278, in fields_view_get
    xarch, xfields = self.__view_look_dom_arch(cr, user, result['arch'], view_id, context=ctx)
  File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 1955, in __view_look_dom_arch
    raise except_orm('View error', msg)
except_orm: ('View error', u"Can't find field 'mct_projects_machine' in the following view parts composing the view of object model 'project.project':\n * project.project.form\n\nEither you wrongly customized this view, or some modules bringing those views are not compatible with your current data model")
2014-05-28 17:56:13,128 29680 ERROR mct openerp.tools.convert: Parse error in /usr/lib/pymodules/python2.7/openerp/addons/mct_projects/mct_projects.xml:4: 
<record model="ir.ui.view" id="mct_projects_project">
         <field name="name">project.project.form</field>
         <field name="model">project.project</field>
         <field name="inherit_id" ref="project.edit_project"/>
         <field name="arch" type="xml">
            <xpath expr="//field[@name='partner_id']" position="after">
               <field name="mct_projects_machine"/>
            </xpath>
         </field>
      </record>

__ init __.py:

__init__.py:

from openerp.modules import get_module_resource, get_module_path
import mct_projects

mct_projects.py:

mct_projects.py:

from openerp.osv import fields, osv

class mct_projects(osv.osv):

    _inherit = 'project.project'

    _columnns = {
        'mct_projects_machine': fields.integer('Mct projects Machine', size=11),
        }
    _defaults ={
    }

mct_projects()

mct_projects.xml:

mct_projects.xml:

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
   <data>
      <record model="ir.ui.view" id="mct_projects_project">
         <field name="name">project.project.form</field>
         <field name="model">project.project</field>
         <field name="inherit_id" ref="project.edit_project" />
         <field name="arch" type="xml">
            <xpath expr="//field[@name='partner_id']" position="after">
               <field name="mct_projects_machine" />
            </xpath>
         </field>
      </record>
   </data>
</openerp>

__ openerp __.py

__openerp__.py

{
    'name': "MCT project integration",
    'version': "1.0",
    'author': "XYZ",
    'category': "Tools",
    'depends': ['project'],
    'data': ['mct_projects.xml'],
    'demo': [],
    'installable': True,
}

据我的诊断,"arch"字段有问题.似乎在说mct_projects_machine不是曾经创建的字段,但是我在mct_projects.py中声明了它,所以我很茫然.我完全按照该教程进行操作,并且在此处有关stackoverflow的另一篇文章通过更改xpath表达式进行了修复,因此我尝试了这一点.那是我现在的代码和本教程之间的唯一区别-两种方式我都遇到相同的错误.任何帮助将不胜感激.

As far as my diagnoses goes it's something wrong with the "arch" field. It seems to be saying that mct_projects_machine isn't a field that was ever created, but I declared it in mct_projects.py so I'm at a loss. I followed the tutorial exactly, and a different post here on stackoverflow was fixed by changing the xpath expression, so I tried that. That is the only difference between how my code is now and the tutorial-and I get the same error either way. Any help would be greatly appreciated.

推荐答案

该错误是一个非常典型的表单中尚未添加字段的字段",乍一看,这很奇怪,您的模型和模块看起来不错.

That error is a pretty typical "form has a field that hasn't been added to the model" which is odd as at first glance, your model and module look fine.

我唯一要说的是,假设您使用的是OpenERP 6.1或更高版本,则无需在mct_projects.py的末尾实例化模型,从而可以松开mct_projects().

The only comments I would make is assuming you are OpenERP 6.1 or greater, you don't need to instantiate your model at the end of mct_projects.py so you can loose the mct_projects().

您还应该从 init .py文件中的openerp.modules ...行中删除该行.

You should also remove the from openerp.modules... line in your init.py file.

我最初的怀疑是该领域尚未进入模型.在ir_model_fields表中查看或在设置"->数据库"下查看.我还将检查您的插件路径以确保找到代码-OpenERP启动后立即记录插件路径.最终的想法是,使用调试器运行并在列上设置一个断点,以查看代码是否正在解析.

My initial suspicion would be that the field hasn't made it's way into the model. Have a look in the ir_model_fields table or look under Settings -> Database. I would also check your addons path to ensure the code is being found - the addons path is logged as soon as OpenERP starts. As a final idea, run with the debugger and set a break point on your columns to see if the code is being parsed.

这篇关于OpenERP 7将字段添加到现有模块-XML验证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆