2013-01-04 20 views
3

我已經教程做出新的單模在OpenERP 6,我做了4個文件:在OpenERP的製作新的單模6

1. __init__.py 
2. __openerp__.py 
3. sim.py 
4. sim_view.xml 

當我完成了所有,我已經重新啓動我的OpenERP服務,然後創建一個新的數據庫並刷新我的OpenERP。然後我以管理員身份登錄,但是我發現我的模塊'sim',但是當我嘗試安裝它時,出現錯誤"NameError: name 'osv' is not defined".什麼是錯誤的?

真的需要你的幫助!

__init__.py

import sim 

sim.py

class student(osv.osv): 
    _name = "sim.student" 
    _description = "This table is for keeping personal data of student" 
    _columns = { 
     'name': fields.char('Registration Number',size=256,required=True), 
     'student_name': fields.char('Student Name',size=256,required=True), 
     'father_name': fields.char('Father Name',size=256), 
     'gender':fields.selection([('male','Male'),('female','Female')],'Gender'), 
     'contact_no':fields.char('Contact Number',size=256) 
    } 
student() 

__openerp__.py

{ 
'name': 'Student Information Management', 
'version': '0.1', 
'category': 'Tools', 
'description': """This module is for the Student Information Management.""", 
'author': 'Mir Nauman Tahir', 
'website': 'http://mirnauman.wordpress.com/', 
'depends': ['base'], 
'init_xml': [], 
'update_xml': ['sim_view.xml'], 
'demo_xml': [], 
'installable': True, 
} 

sim_view.xml

<?xml version="1.0"?> 
<openerp> 
<data> 
<!-- ============== student================= --> 
<!-- 1st part of the sim_view start--> 
<record model="ir.ui.view" id="student_form"> 
<field name="name">Student</field> 
<field name="model">sim.student</field> 
<field name="type">form</field> 
<field name="arch" type="xml"> 
<form string="Student"> 
<field name="name"/> 
<field name="student_name"/> 
<field name="father_name"/> 
<field name="gender"/> 
<field name="contact_no"/> 
</form> 
</field> 
</record> 
<!-- 1st part of the sim_view end--> 
<!--2nd part of the sim_view start--> 
<record model="ir.ui.view" id="student_tree"> 
<field name="name">Student</field> 
<field name="model">sim.student</field> 
<field name="type">tree</field> 
<field name="arch" type="xml"> 
<tree string="Student"> 
<field name="name"/> 
<field name="student_name"/> 
<field name="father_name"/> 
<field name="gender"/> 
<field name="contact_no"/> 
</tree> 
</field> 
</record> 
<!--2nd part of the sim_view end--> 
<!-- 3rd part of the sim_view start--> 
<record model="ir.actions.act_window" id="action_student"> 
<field name="name">Student</field> 
<field name="res_model">sim.student</field> 
<field name="view_type">form</field> 
<field name="view_mode">tree,form</field> 
</record> 
<!--3rd part of the sim_view end--> 
<!--4th part of the sim_view start--> 
<menuitem&nbsp;name="SIM/Student/StudentInfo" id="menu_sim_student" action="action_student"/> 
<!--4th part of the sim_view end--> 
</data> 
</openerp> 
+0

請給錯誤的完整堆棧跟蹤。 – Nilesh

回答

2

你有沒有在sim.py文件中提到from osv import osv

請按照Create Module頁面中的步驟操作。

注意:如果在sim.py文件中導入了osv,那麼檢查PYTHONPATH變量是否包含openerp的基目錄。

+0

哪裏可以找到PYTHONPATH變量? –

3

以下也需要添加新字段

from osv import osv,fields 
4

作爲6.1,osvdeprecated。你sim.py文件應該首先:

from openerp.osv import fields, orm 

class student(orm.Model): 
    #model definitions go here...