Kevin Randriajaoson
Kevin Randriajaoson

Reputation: 121

Trying to inherit hr.employee but getting error

So I'm trying to inherit hr.employee in odoo but there's an error that I don't know why since I'm doing it like in the tutorials. (Link to the tutorial)

Here's my code: in

employee.py

class Employee(models.Model):
""" Class Employee """
_inherit = 'hr.employee'
_description = 'A custom class of employee'

esia = fields.Float(digits=(12, 2))
cnaps = fields.Float(digits=(12, 2))

employees.xml

<record model="ir.ui.view" id="employee_form_view">
    <field name="name">employee.form</field>
    <field name="model">hr.employee</field>
    <field name="inherit_id" ref="hr.view_employee_form"/>
    <field name="arch" type="xml">
        <notebook position="inside">
            <page string="Sécurité Sociale">
                <group>
                    <field name="cnaps"/>
                    <field name="esia"/>
                </group>
            </page>
        </notebook>
    </field>
</record>
<record model="ir.actions.act_window" id="employee_list_action">
    <field name="name">Employees</field>
    <field name="res_model">hr.employee</field>
    <field name="view_mode">tree,form</field>
</record>

And what I get as error when trying to upgrade my module is:

Invalid model name 'hr.employee' in action definition

Upvotes: 1

Views: 1392

Answers (1)

Kevin Randriajaoson
Kevin Randriajaoson

Reputation: 121

Thanks to @Amal, I defined hr module in _manifest_.py then it worked. Added hr here: 'depends': ['base', 'hr'],

Upvotes: 3

Related Questions