Odoo ParseError:“视图定义无效错误详细信息:未找到模型

时间:2016-02-26 11:09:34

标签: python postgresql xml-parsing odoo-9

从昨天开始,我正在尝试在Odoo 9上安装模块,但我得到了这个 错误:

Odoo ParseError: "Invalid view definition 
Error detail : 
Model not found:employee.register

Context of error :
View `employee.form`
[view_id: 547, xml_id: n/a, model: employee.register, parent_id: n/a]
None" while parsing /opt/odoo/addons/lci_gestpaie_tic/views/employee.xml:7, near

<record model="ir.ui.view" id="employee_form">
    <field name="name">employee.form</field>  
    <field name="model">employee.register</field>
    <field name="arch" type="xml">
        <form string="Employee">

            <label string="Nom"/>
            <field name="nom"/>

            <label string="Prenom"/>
            <field name="prenom"/>

            <label string="Date de Naissance"/>
            <field name="date_naissance"/>

            <label string="Lieu de naissance"/>
            <field name="lieu_naissance"/>

            <label string="CNI"/>
            <field name="cni"/>

            <label string="Salaire de Base"/>
            <field name="salaire_base"/>

            <label string="Date embauche"/>
            <field name="date_embauche"/>

            <label string="Sexe"/>
            <field name="sexe"/>

            <label string="Situation matrimoniale"/>
            <field name="situation_matrimoniale"/>

            <label string="Nombre enfants"/>
            <field name="nombre_enfant"/>

            <label string="Telephone"/>
            <field name="telephone"/>

            <label string="Email"/>
            <field name="email"/>
        </form>
    </field>
</record>

这是我的模块和源代码

的结构
my_module
    |models
        | __init__.py
        | emlpoyee.py
    |views
        | employee.xml
    __init__.py
    __openerp__.py

my_modules。的初始化的.py

import models

../模型。的初始化的.py

import employee

../模型。的 OpenERP的的.py

{
    'name': 'LCI',
    'version': '0.1',
    'category': 'LCI',
    'summary': """
        Summary of the module
    """,
    'author': 'LCI Sarl',
    'website': 'http://lcicm.com',
    'depends': ['base'],
    'data': ['views/employee.xml'],
    'installable': True,
    'auto_install': False,
}

../ views.employee.xml

<?xml version="1.0" ?>
<openerp>
<data>

    <!--formulaire enregistrement-->
    <record model="ir.ui.view" id="employee_form">
        <field name="name">employee.form</field>  
        <field name="model">employee.register</field>
        <field name="arch" type="xml">
            <form string="Employee">

                <label string="Nom"/>
                <field name="nom"/>

                <label string="Prenom"/>
                <field name="prenom"/>

                <label string="Date de Naissance"/>
                <field name="date_naissance"/>

                <label string="Lieu de naissance"/>
                <field name="lieu_naissance"/>

                <label string="CNI"/>
                <field name="cni"/>

                <label string="Salaire de Base"/>
                <field name="salaire_base"/>

                <label string="Date embauche"/>
                <field name="date_embauche"/>

                <label string="Sexe"/>
                <field name="sexe"/>

                <label string="Situation matrimoniale"/>
                <field name="situation_matrimoniale"/>

                <label string="Nombre enfants"/>
                <field name="nombre_enfant"/>

                <label string="Telephone"/>
                <field name="telephone"/>

                <label string="Email"/>
                <field name="email"/>
            </form>
        </field>
    </record>

    <!--affichage de la liste des employes-->
    <record model="ir.ui.view" id="employee_tree">
        <field name="name">employee.tree</field>
        <field name="model">employee.register</field>
        <field name="type">tree</field>

        <field name="arch" type="xml">
            <tree string="Employee List">

                <field name="nom"/>
                <field name="prenom"/>
                <field name="date_naissance"/>
                <field name="lieu_naissance"/>
                <field name="cni"/>                  
                <field name="salaire_base"/>
                <field name="date_embauche"/>
                <field name="sexe"/>
                <field name="situation_matrimoniale"/>
                <field name="nombre_enfant"/>
                <field name="telephone"/>
                <field name="email"/>

            </tree>
        </field>
    </record>

    <!--actions qui seront executees-->
    <record model="ir.actions.act_window" id="action_employee">
        <field name="name">Employee</field>
        <field name="res_model">employee.register</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>

    <!--nos differents menus-->
    <menuitem name="GestPaie" id="lci_gestpaie_tic"/>
    <menuitem name="Employee" id="employee_gestpaie_section" parent="lci_gestpaie_tic"/>
    <menuitem name="Create Employee" id="employee_register" parent="employee_gestpaie_section" action="action_employee"/>

</data>
</openerp>

../模型/ employee.py

from openerp import fields, models

class EmployeeRegister(models.Model):
    _name = 'employee.register'

    # attributs de Employee
    nom = fields.Char(required=True)
    prenom = fields.Char(required=True)
    date_naissance = fields.Date(required=True)
    lieu_naissance = fields.Char(required=True)
    cni = fields.Char(required=True)
    salaire_base = fields.Integer(required=True)
    date_embauche = fields.Date(required=True)
    sexe = fields.Char(required=True) # M pour Masculin, F pour Feminin
    situation_matrimoniale = fields.String()
    nbre_enfant = fields.Integer()
    telephone = fields.Char(required=True)
    email = fields.Char(required=True)

请帮助!!!

3 个答案:

答案 0 :(得分:1)

我已经解决了问题,这是一个缓存问题,所以我做了

./openerp_server stop

然后

./openerp_server stop

答案 1 :(得分:0)

my_module/models/__init__.py中应该是导入employee的行:

import employee

答案 2 :(得分:0)

这样做,它会正常工作。

在my_module / models / init .py应该是导入员工的行:

from . import employee