Odoo Help


how to inherit field from one module to another module?

Demirel yakito
on 2/17/15, 7:19 AM 8,193 views

i want to use one field in 'hr.contract' module to 'hr.employee' module.

field name in 'hr.contract' is type_id. i want to use this field in 'hr.employee' .

is this correct?

from openerp import models, fields, api, _
class Hremployee(models.Model):


<?xml version="1.0" encoding="UTF-8"?>
        <record model="ir.ui.view" id="employee_registration_form_view1234">
            <field name="name">Employee Registration</field>
            <field name="model">hr.employee</field>
            <field name="type">form</field>
            <field name="inherit_id" ref="hr.view_employee_form" />
            <field name="arch" type="xml">
                    <label for="employee" />
                    <field name="employee" />
                    expr="//form/sheet/div[@class='oe_title']/field[@name='employee']" position="after">
                    <label for="type_id" />
                    <field name="type_id" />



        <act_window name="Employee" domain="[('employee', '=', True)]"
            res_model="hr.employee" context="{'default_employee': True}" id="employee_action1234" view_mode="tree,form"/>

        <menuitem name="Add Employee" id="add_e6hjfgjf1234" parent="check_sub_menu"




| 5 3 6
Jakarta, Indonesia
On 2/17/15, 7:38 AM

You don't inherit fields.  If you see, the one hr.contract has one hr.employee.  Hence an hr.employee can have multiple contracts.  The type_id field is a many2one field to hr.contract.type.

  • If you need to have the type_id field in hr.employee and the content of which has nothing to do with the employee's contract, then you can just add (copy) the type_id field from hr.contract to hr.employee.  To do so, you need to inherit the hr.employee model.
  • If you need to see what are the employee's contract type, you can just show the Contracts (contract_ids) field in hr.employee's view and display the type_id field.
  • If you need to see what is the type_id of the lastest contract (by date_start) that employee is attached to, there is another field called contract_id in hr.employee.  You can add a related field via contract_id to get the type_id of the latest contract.

ok thnks

Demirel yakito
on 2/17/15, 7:49 AM
On 5/29/15, 6:03 AM

I want inherit customer fracture view from accounting model to another custom module!but it doesn't work!!can anybody help me please!this is my code:

from openerp.osv import fields, osv

class dimo_dimo(osv.osv):

_name = 'dimo.dimo'

_inherit = 'account.invoice.line'



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

<field name="name">account.invoice.tree.inherit</field>

<field name="model">account.invoice</field>

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

<field name="inherit_id" ref="account.invoice_tree"/>



About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 2/17/15, 7:19 AM
Seen: 8193 times
Last updated: 6/26/17, 1:01 PM