I have a tree view with certain custom fields from employees, in this tree view I have included a button in each line and I pretend that clicking on that button, should open the employee card for the selected employee.
My code is as follows:
Tree view:
<record model="ir.ui.view" id="informes_informe_empleados_tree">
<field name="name">informes.informe_empleados.tree</field>
<field name="model">informes.informe_empleados</field>
<field name="arch" type="xml">
<tree>
<button name="open_form_empleados" string="Abrir ficha" type="object" class="oe_highlight"/>
<field name="name"/>
<field name="employee_type_principal"/>
<field name="begin_date"/>
<field name="end_date"/>
</tree>
</field>
</record>
And the function called by the button:
def open_form_empleados(self):
return {
'type': 'ir.actions.act_window',
'view_type': 'form',
'res_id': "I don't know what to put here",
'view_mode': 'form',
'res_model': 'hr.employee',
'view_id': self.env.ref('per_employee_model.hr_employee_inherit').id,
'target': 'new'
}
I have made some research and I think that I have to use res_id to indicate the employee id but I didn't manage to find the correct syntax to make it work.
I would appreciate any hint. Thanks in advance.