Inherit OpenERP Models:
There are two ways of Inheritance in openerp:-
1-Object Inheritance - _inherit
2-view inheritance
1-Object Inheritance -
Objects may be inherited in some custom or specific modules. It is better to inherit an object to add/modify some fields. This inheritance can be done by two possible ways and both the ways result in a new class of data, which holds parent fields and behavior as well as additional fields and behavior but they differ in heavy programmatical consequences.
Example- inherit account module object in openerp
from osv import fields, osv
class invoice_order_test(osv.osv):
_name='account.invoice'
_inherit='account.invoice'
_columns={
'cartage':fields.float('Cartage',readonly=False),
'credit_note':fields.text('Credit Note',readonly=True),
}
2-view inheritance:-
In openerp you have to inherit only view form of account module and add some new field
in account module.
Example- inherit account module view in openerp
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="invoice_form" model="ir.ui.view">
<field name="name">account.invoice.form.inherit</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form" />
<field name="arch" type="xml">
<field name="amount_untaxed" position="after">
<field name="cartage"/>
<field name="credit_note"/>
</field>
</field>
</record>
</data>
</openerp>
0 Comment(s)