请从昨天开始我试图在 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
我的模块。初始化.py
import models
../楷模。初始化.py
import employee
../楷模。开放程序.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>
../models/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)