我怎样才能从openerp类/视图继承

时间:2014-04-04 12:24:11

标签: python inheritance openerp-7

如何创建视图以继承此类?

- 基类:

from openerp.osv import fields, osv

class pos_personne(osv.osv):
_name = 'pos.personne1'
_columns = {
'pos_personne_id' : fields.integer('ID',size=64),
'personne_nom': fields.char('Nom de la personne', size=128, required=True),
'personne_prenom': fields.char('Prenom de la personne', size=128, required=True),
'personne_date': fields.date('Date Naissance'),
'personne_lieu': fields.char('LIeu Naissance', size=128, required=True),
'personne_travail':fields.char('Travail de la personne', size=128, required=True),
}

_defaults = {
'personne_nom' : '',
'personne_prenom': '',
}

pos_personne()

---这是基本视图

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="pos_personne_form" model="ir.ui.view">
<field name="name">pos.personne1.form</field>
<field name="model">pos.personne1</field>
<field name="arch" type="xml">
<form string="personne" version="7.0">
<group col="4">
<field name="pos_personne_id" />
<field name="personne_nom" />
<field name="personne_prenom" />
<field name="personne_date" />
<field name="personne_lieu" />
<field name="personne_travail" />
</group>
</form>
</field>
</record>

<record id="pos_personne_tree" model="ir.ui.view">
<field name="name">pos.personne1.tree</field>
<field name="model">pos.personne1</field>
<field name="arch" type="xml">
<tree string="personne">
<field name="pos_personne_id" />
<field name="personne_nom" />
<field name="personne_prenom" />
<field name="personne_date" />
<field name="personne_lieu" />
<field name="personne_travail" />
</tree>
</field>
</record>

<record model="ir.ui.view" id="pos_personne_search">
<field name="name">pos.personne1.search</field>
<field name="model">pos.personne1</field>
<field name="arch" type="xml">
<search string="personne Management">
<field name="personne_nom" />
</search>
</field>
</record>

<menuitem name="Faculty Management" id="menu_point_root"
sequence="30" />

<record model="ir.actions.act_window" id="action_pos_personne">
<field name="name">personne</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">pos.personne1</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="pos_personne_tree" />
<field name="context">{"search_default_filter_see_all":1}</field>
<field name="help" type="html">

Click here to create a Personnes for Hachem.
</field>
</record>

<menuitem name="personnes Menu" id="menu_point_root_personnes"
parent="menu_point_root" sequence="19" />
<menuitem id="menu_action_pos_personne" parent="menu_point_root_personnes"
action="action_pos_personne" />
<!-- # -->

</data>
</openerp>

- 这是继承类

from openerp.osv import fields, osv

class pos_personneFils(osv.osv):
_name = 'pos.personnefils1'
_inherit = 'pos.personne'
_columns = {
'numero':fields.char('Numero',size=64,required=True),
}

_defaults = {
'numero' : '',
}

pos_personneFils()

这个继承类是否正确?如何构建继承视图?

1 个答案:

答案 0 :(得分:0)

试试这个,

<record id="pos_personne_form1" model="ir.ui.view">
            <field name="name">pos.personne1.form</field>
            <field name="model">pos.personne1</field>
            <field name="inherit_id" ref="pos_personne.pos_personne_form"/>
            <field name="arch" type="xml">
            <xpath expr="/form/group">
                    <field name="numero"/>
            </xpath>
            </field>
</record>