odoo - 在 OpenERP 6 中制作新的简单模块

标签 odoo

我有在 OpenERP 6 中制作新的简单模块的教程,我制作了 4 个文件:

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

完成所有操作后,我重新启动了 OpenERP 服务,然后创建了一个新数据库并刷新了我的 OpenERP。然后我以管理员身份登录,但我找到了我的模块“sim”,但是当我尝试安装它时,出现错误“NameError:名称'osv'未定义”。出了什么问题?

真的需要你们的帮助!

__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>

最佳答案

从 6.1 开始,osvdeprecated 。您的 sim.py 文件应以以下内容开头:

from openerp.osv import fields, orm

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

关于odoo - 在 OpenERP 6 中制作新的简单模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14150749/

相关文章:

odoo - 如何在odoo网站上上传图片?

python - 工作流程按钮 Odoo v8

python - 通过代码创建 account.move - Odoo v8

odoo - 如何在 odoo 中打开默认过滤器 AND 在一起?

python - 无法在 ubuntu 10.04 上的 openERP7 安装中加载模块 Web

datetime - 如何将 `write_date` 的值获取到变量

odoo - 如何为 Odoo 安装 ftputil?

postgresql - 如何将 postgres 数据库用户角色密码从 'admin' 更改为 'mypassword'?

javascript - 如何防止 odoo 10 中的异步执行?

javascript - odoo 12中many2many字段标签上的点击事件