Shridhar Ivani
Shridhar Ivani

Reputation: 467

How to inherit hr.employee module in openerp(odoo)

This is my code and i am getting this error. I tried to inherit the hr.employee and in hr.employee model, I had added four custom fields and one of them is 'x_doj'

    ParseError: "ValidateError
    Field(s) `arch` failed against a constraint: Invalid view definition

    Error details:
    Field `x_doj` does not exist

    Error context:
    View `hr.employee`
    [view_id: 939, xml_id: n/a, model: hr.employee, parent_id: 813]" while parsing /home/administrator/Sub_Station/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/addons/hredit1/hredit_view.xml:5, near
    <record id="hr_inheritedview_employee_form1" model="ir.ui.view">
                <field name="name">hr.employee</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">
                    <notebook position="inside">
                        <page string="Empl Resource">   
                            <field name="deal" nolabel="1"/> 
                        </page>
                    </notebook>
                </field>


            </record>

my hredit.py 
from openerp.osv import fields, osv

    class empl(osv.Model):
        _inherit='hr.employee'
        _columns = {
            'deal':fields.char('done',size=20)
        }

    empl()





this my xml code hredit.xml

<?xml version="1.0" encoding="utf-8"?>

<openerp>
    <data>
        <record id="hr_inheritedview_employee_form1" model="ir.ui.view">
            <field name="name">hr.employee</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">
                <field name="work_phone" position="after">  
                        <field name="deal" /> 
                    </field>

            </field>


        </record>


    </data>
</openerp>

in hr.employee.form also tried

my openerp.py file

{
    'name': 'Hr Edit',
    'version':'1.0',
    'description': """
        Hr Edit
        - Epics
    """,
    'author': 'Shridhar',
    'depends': ['base_setup'],
    'data': ['hredit_view.xml',],
    'installable': True,
    'auto_install': False,
}

and in init.py i have done import hredit

Upvotes: 1

Views: 3783

Answers (2)

raBinn
raBinn

Reputation: 182

I had the same problem and solve in openerp.py

This is my solution:

# -*- coding: utf-8 -*-
{
    'name': 'nombre de modulo',

    'summary': """

        """,

    'description': """
    descripcion
    """,

    'author': '--',
    'website': "http://www.yoursite.com",
    'category': '--',
    'version': '0.1',
    **'depends': ['base', 'hr', 'hr_expense'],**
    'data': [
        'views/gi_hr_expense_view.xml',
    ],

    'installable': True,
    'auto_install': False,
}

Upvotes: 0

DASADIYA CHAITANYA
DASADIYA CHAITANYA

Reputation: 2892

Hello Shridhar Ivani,

In this case you must need to set the dependent module name in your __openeerp__.py file.

hear hr.employee model comes from the HR Module but you have not yet set as dependent module as the hr in your __openerp__.py file

You can add the hr from the depends in your __openerp__.py file and upgrade your module list as well as your module then every things will work fine.

I hope this should helpful for you ..:)

Upvotes: 1

Related Questions