0

我在 Windows 7.0 上有 OpenERP 7.0。如何在我的自定义模块中添加员工姓名字段?谢谢。

初始化文件

导入笔记本

开放程序.py

{

"name" : "notebook",

"version" : "0.1",

"author" : "Jamil Shah",

"website" : "http://www.asp-aid.org/",

"category" : "Generic Modules/Others",

"depends" : ["hr"],

"description" : "Simple demo module",

"init_xml" : ["notebook_view.xml"],

"demo_xml" : [],

"update_xml" : [],

"active": False,

"installable": True

}

笔记本.py

从 openerp.osv 导入字段,orm

课堂笔记本(orm.Model):

_name = "notebook"
    _inherit = 'hr.employee'

_description = "Simple Notebook"

_columns = {

    'employee_id' : fields.many2one('hr.employee', 'Employee'),

    'title' : fields.char('Title', size=30, required=True),

    'note' : fields.text('Note'),

    'note_date' : fields.date('Date'),

}

笔记本()

notebook_view.xml

<data>

    <record model="ir.ui.view" id="notebook_tree_view">

        <field name="name">notebook.tree</field>

        <field name="model">notebook</field>

        <field name="type">tree</field>

        <field name="arch" type="xml">

            <tree string="Notebook">

                <field name="title"/>

                <field name="note"/>

                <field name="note_date"/>

            </tree>

        </field>

    </record>


    <record model="ir.ui.view" id="notebook_form_view">

        <field name="name">notebook.form</field>

        <field name="model">notebook</field>

        <field name="type">form</field>

        <field name="arch" type="xml">

            <form string="Notebook" version="7.0">

                <field name="title"/>

                <field name="note"/>

                <field name="note_date"/>

            </form>

        </field>

    </record>


    <record model="ir.actions.act_window" id="action_notebook_form">

        <field name="name">notebook</field>

        <field name="res_model">notebook</field>

    </record>

    <menuitem id="notebook_menu"
        name="Notebook"
        icon="terp-project"
    />


    <menuitem id="notebook_sub_menu"
        name="Notes"
        parent="notebook_menu"
    />


    <menuitem id="notebook_menu_mainform"
        name="Notes"
        action="action_notebook_form"
        parent="notebook_sub_menu"
    />


</data>

4

1 回答 1

0
class hr_employee(osv.Model):
    _name = 'class.name'
    _columns = {
        'date': fields.date('Date'),
        'employee_id': fields.many2one('hr.employee', 'Employee'),
        'note': fields.text('Note'),
        'name': fields.char('Details', size=50),
    }

您可以获得更多信息Create New Object

于 2013-03-07T09:31:34.000 回答