1
votes

I was trying to add a extra field in hr module i.e in hr.employee object by inheritance but when I'm adding that field ,in Hr module employee form my given field is not displayed .So pls help. All I want to do is create another seperate module so whenever that module is installed then that column should appear.(my field jdate should appear after coach_id field)

class joining_date(osv.osv):
   _name="joining.date"
   _inherit = "hr.employee"
   _columns={
          'jdate':fields.date('Joining date'),
          }


 joining_date()

xml part:

<?xml version="1.0" encoding="UTF-8"?>
  <openerp>
  <data>
     <record id="view_join_date" model="ir.ui.view">
     <field name="name">Join_date</field>
     <field name="model">joining.date</field>
     <field name="inherit_id" ref="hr.view_employee_form"/>
     <field name="arch" type="xml">
        <data>
        <xpath expr="//form/sheet/notebook/page/group[1]/group[2][@name='coach_id']" position="after">
            <field name="jdate"/>
        </xpath>
        </data>
      </field>
      </record>

openerp file:

{
'name': 'HR join date',
'version': '1.0',
'category': 'Tools',
'description': """ To add extra join date field""",
'author': 'Greywind',
'website': 'http://www.greywind.com',
'depends': ['hr','base', 'account_accountant'],
'data': [
         'joindate_view.xml'],
'demo': [],
'installable': True,
'auto_install': False,

}

2

2 Answers

0
votes

I think your XML should look like this:

<record id="view_join_date" model="ir.ui.view">
    <field name="name">Join_date</field>
    <field name="model">joining.date</field>
    <field name="inherit_id" ref="hr.view_employee_form"/>
    <field name="arch" type="xml">
        <field name="coach_id" position="after">
            <field name="jdate"/>
        </field>
    </field>
</record>
0
votes

Try to -name and -inherits field as the same id. if its so you can add your field in to the inherited module.

Then ref=base module view idand also if you want all the fields of your base module to your new module then you just change ref = **base module view id . new module view id you should create the view for the new module with all the fields you needed from base & new field.

You should refer MrEthan Furman xml code.