尝试继承hr.employee,但出现错误

时间:2019-04-03 08:28:06

标签: odoo odoo-view odoo-12

所以我试图在odoo中继承hr.employee,但是由于我像在教程中那样进行操作,所以我不知道为什么会出错。 (Link to the tutorial

这是我的代码:

  

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>

在升级模块时出现的错误是:

Invalid model name 'hr.employee' in action definition

1 个答案:

答案 0 :(得分:2)

由于@Amal,我在_manifest_.py中定义了hr模块,然后它起作用了。 在此处添加了hr'depends': ['base', 'hr'],