自定义模块安装失败。表无法创建还是视图有错?
-
按照此例:<br / [检测到链接无效,已移除] br />编写的模块,在7.0安装时遇到错误:
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=cont$
AttributeError: 'NoneType' object has no attribute 'fields_view_get'
2013-07-30 07:03:04,529 20870 ERROR bsec openerp.tools.convert: Parse error in /opt/openerp/addon/oecn_training$
<record model="ir.ui.view" id="oecn_training_lesson_from_view">
<field name="name">课程表单</field>
<field name="type">form</field>
<field name="model">oecn.training.lesson</field>
<field name="arch" type="xml">
<form string="课程表单">
<field name="name"/>
<field name="date_start"/>
<field name="total_day"/>
<field name="price"/>
<field name="teacher"/>
<field name="students" colspan="4"/>
</form>
</field>
</record>
验证字段 arch 时发生错误:Invalid XML for View Architecture!
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/openerp/netsvc.py", line 292, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/usr/lib/pymodules/python2.7/openerp/service/web_services.py", line 626, in dispatch
res = fn(db, uid, *params)
File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 188, in execute_kw
return self.execute(db, uid, obj, method, *args, **kw or {})
File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 144, in wrapper
raise except_osv(inst.name, inst.value)
错误的核心有两处,
一是
AttributeError: 'NoneType' object has no attribute 'fields_view_get'
此错误在launchpad上能找到相关的bug:<br / https://www.google.com.hk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&ved=0CEAQFjAC&url=https%3A%2F%2Fbugs.launchpad.net%2Fbugs%2F1077794&ei=Kmj3UY2eEsmXkwWuuoDIDg&usg=AFQjCNFzGWu7j6hd-wpbZMKINCIFL_2Bag br /> 明确说明此错误描述本身不清晰,应该是对象不存在导致xml结构验证错误,
二是
验证字段 arch 时发生错误:Invalid XML for View Architecture!
此位置一再验证无法看到错误,且有一的bug描述,应该不是根本原因。
数据库中确实没有我新增的oecn.training.lesson表存在。。。 -
搞两天居然还没搞定这个,信心受打击了呀~请大大帮忙则个:
init.py
# -- encoding: utf-8 --
import lesson
openerp.py
{
"name" : "OECN Training", #模块名
"version" : "1.0", #模块版本
"description" : "OCEN training Demo", #说明
"author" : "xmbcit", #作者
"website" : "http://www.xmbcit.net", #网站
"depends" : [], #依赖
"data" : ["lesson_view.xml"],#读入的文件
"installable" : True, #可安装
"category" : "Generic Modules/Others" #类型
}
lesson.py
# -- coding: utf-8 --
from openerp.osv import fields, osv
class oecn_training_lesson(osv.osv):
_name = 'oecn.training.lesson'
_discription = 'OECN 培训课程'
_columns = {
'name':fields.char( u'课程名',size=64,select=True),
'date_start':fields.date(u'开始日期',select=True),
'total_day':fields.float(u'总天数',digits=(16,1)),
'teacher':fields.many2one('res.users',u'授课老师'),
'students':fields.many2many('res.partner',string=u'学生'),
'price':fields.float(u'价格',digits=(16,2)),
}
oecn_training_lesson()
lesson_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!--定义表单视图-->
<record model="ir.ui.view" id="oecn_training_lesson_from_view">
<field name="name">课程表单</field>
<field name="type">form</field>
<field name="model">oecn.training.lesson</field>
<field name="arch" type="xml">
<form string="课程表单">
<field name="name"/>
<field name="date_start"/>
<field name="total_day"/>
<field name="price"/>
<field name="teacher"/>
<field name="students" colspan="4"/>
</form>
</field>
</record>
<!--定义列表视图-->
<record model="ir.ui.view" id="oecn_training_lesson_tree_view">
<field name="name">课程列表</field>
<field name="type">tree</field>
<field name="model">oecn.training.lesson</field>
<field name="arch" type="xml">
<tree string="课程列表">
<field name="name"/>
<field name="date_start"/>
<field name="teacher"/>
<field name="price" sum="合计"/>
</tree>
</field>
</record>
<!--定义视图动作-->
<record model="ir.actions.act_window" id="action_oecn_training_lesson">
<field name="name">课程</field>
<field name="res_model">oecn.training.lesson</field>
<field name="view_type">form</field>
<field name="view_mode">form,tree</field>
<field name="view_id" ref="oecn_training_lesson_tree_view"/>
</record>
<!--定义菜单-->
<menuitem id="oecn_menu" name="OECN"/>
<menuitem id="oecn_training_menu" name="OECN Training" parent="oecn_menu"/>
<menuitem id="oecn_training_lesson_menu" name="OECN Training Lesson" parent="oecn_training_menu" action="action_oecn_training_lesson"/>
</data>
</openerp>