Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
4473 มุมมอง

i was trying to add a field on the view form of hr.department using a custom module so i declared the field in my_model.py

   class my_clas(models.Model):

    _name = 'depart.field' 

    _inherit = "hr.department"

     my_field = fields.Char('My field')


and on the my_file.xml i proceeded this way 

    <record id="view_hr_department_inherit" model="ir.ui.view">

                <field name="name">hr.department.form.inherit</field>

                <field name="model">hr.department</field>

                <field name="inherit_id" ref="hr.view_department_form"/>

                <field name="arch" type="xml">

                    <xpath expr="//form/sheet/group/field[@name='name']" position="after">

                       <field name="my_field"/>

                    </xpath>

                </field>

    </record>

i added the xml file to Data ['my_file.xml',]
and i added the my_module to ir.model.access.csv 
access_depart_field,access_depart_field,model_depart_field,base.group_user,1,1,1,1

but i get the following error 
Field `namee` does not exist

Error context:
View `hr.department.form.inherit`

am i missing something here ? 
thanks in advance 
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

can you update the class like this and see,

class my_class(models.Model):
_inherit = "hr.department"

my_field = fields.Char('My field')


Thanks

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hello HimaOdoo,

Apart of above all the answers you should also check the depends of your custom module.

hr.department model is part of hr module so that

HR module must be depends on your__manifest__.py file of your custom module.





อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

thanks it works, after i removed the _name declaration i had to change the file securtiy content as well, thanks again.  

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
มิ.ย. 23
4400
1
ก.ย. 21
5464
1
มี.ค. 21
5871
2
พ.ค. 20
3798
5
พ.ค. 20
2149