someone can help me with _inherit in odoo 12
in my .py i have
from odoo import fields,api,models
class Employes(models.Model):
_name="employes"
_inherit = 'hr.employee'
categorie= fields.Char(string = "Categorie")
in my .xml file i have
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!--Definition de la vue-->
<record model="ir.ui.view" id="hr_employee_form">
<field name="name">hr.employee.form</field>
<field name="model">hr.employee</field>
<field name="type">tree</field>
<field name="inherit_id" ref='hr.view_employee_tree'/>
<field name="arch" type="xml">
<xpath expr = "//field[@name='department_id']" position = "before">
<group>
<field name = "categorie"/>
</group>>
</xpath>
</field>
</record>
</odoo>
when i compile this error appear
Le champ `categorie` n'existe pas
Contexte de l'erreur :
Vue `hr.employee.form`
[view_id: 507, xml_id: n/a, model: hr.employee, parent_id: 410]
None" while parsing /root/odoo/addons/Gestion_RH/views/vue_employe.xml:4, near
<record model="ir.ui.view" id="hr_employee_form">
<field name="name">hr.employee.form</field>
<field name="model">hr.employee</field>
<field name="type">tree</field>
<field name="inherit_id" ref="hr.view_employee_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='department_id']" position="before">
<group>
<field name="categorie"/>
</group>>
</xpath>
</field>
</record>
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Hi,
Update the python file like this, no need to give the _name, so copy the below code and see.
class Employes(models.Model):
_inherit = 'hr.employee'
categorie = fields.Char(string="Categorie")
UPDT: In the XML,
<record model="ir.ui.view" id="hr_employee_form">
<field name="name">hr.employee.form</field>
<field name="model">hr.employee</field>
<field name="type">tree</field>
<field name="inherit_id" ref="hr.view_employee_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='department_id']" position="before">
<group>
<field name="categorie"/>
</group>
</xpath>
</field>
</record>
Thanks
thanks for your answer but when i do it another error appear
File "/root/odoo/odoo/addons/base/models/ir_ui_view.py", line 360, in _check_xml
raise ValidationError(_('Invalid view %s definition in %s') % (view.name, view.arch_fs))
odoo.tools.convert.ParseError: "Invalid view hr.employee.form definition in Gestion_RH/views/vue_employe.xml
None" while parsing /root/odoo/addons/Gestion_RH/views/vue_employe.xml:4, near
<record model="ir.ui.view" id="hr_employee_form">
<field name="name">hr.employee.form</field>
<field name="model">hr.employee</field>
<field name="type">tree</field>
<field name="inherit_id" ref="hr.view_employee_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='department_id']" position="before">
<group>
<field name="categorie"/>
</group>>
</xpath>
</field>
</record>
see the updated answer, remove > coming after the </group>
ok after remove > it's success but my field "Categorie" don't appear in the view of employe.
my security file content this
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_hr_employee,access.hr_employee,model_hr_employee,base.group_user,1,1,1,0
and my file .xml become
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!--Definition de la vue-->
<record model="ir.ui.view" id="hr_employee_form">
<field name="name">hr.employee.form</field>
<field name="model">hr.employee</field>
<field name="type">tree</field>
<field name="inherit_id" ref='hr.view_employee_tree'/>
<field name="arch" type="xml">
<xpath expr = "//field[@name='department_id']" position = "before">
<field name = "categorie"/>
</xpath>
</field>
</record>
</odoo>
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký