Skip to Content
Menu
This question has been flagged
1 Reply
1985 Views

I want to display fields related to education so that employees can see each other in the personal information. Here's how I do it

/hr_employee_public.py

certificate = fields.Selection([

        ('graduate', 'Graduate'),

        ('bachelor', 'Bachelor'),

        ('master', 'Master'),

        ('doctor', 'Doctor'),

        ('other', 'Other'),

    ], 'Certificate Level', readonly=True)

    study_field = fields.Char("Field of Study", readonly=True)

    study_school = fields.Char("School", readonly=True)


/hr_employee_public_views.xml

name="personal_information" string="Private Information" groups="hr.group_hr_user">                                

                                    

string="Education">                                       

name="certificate" readonly="1" string="Certificate"/>                                        

name="study_field" readonly="1" string/="Study Field">                                       

name="study_school" reaconly="1"  string="Study School"/>                                    

                                

                            

                                                                                  

I have added 3 fields certificate, study_field, study_school to the View in the DB

Can anyone help me?

Avatar
Discard
Best Answer

1. Define the Fields in the Python Model

class HrEmployeePublic(models.Model):

    _inherit = 'hr.employee.public'


    certificate = fields.Selection([

        ('graduate', 'Graduate'),

        ('bachelor', 'Bachelor'),

        ('master', 'Master'),

        ('doctor', 'Doctor'),

        ('other', 'Other'),

    ], string='Certificate Level', readonly=True)


    study_field = fields.Char(string="Field of Study", readonly=True)

    study_school = fields.Char(string="School", readonly=True)

2. Update the XML View Definition
<record id="view_employee_public_form_inherit" model="ir.ui.view">
<field name="name">hr.employee.public.form.inherit</field>
<field name="model">hr.employee.public</field>
<field name="inherit_id" ref="hr.view_employee_public_form"/>
    <field name="arch" type="xml">
<xpath expr="//group[@name='personal_information']" position="inside">
            <group string="Education">
                <field name="certificate" readonly="1" string="Certificate Level"/>
                <field name="study_field" readonly="1" string="Field of Study"/>
                <field name="study_school" readonly="1" string="School"/>
            </group>
        </xpath>
    </field>
</record>


Hope it helps

Avatar
Discard