Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
6216 Vistas

H, i'd like to know how to add the hr.job field from hr.employee to project.issue kanban view.

I tried this in the model.py

class hr_employee(models.Model):
_inherit = "hr.employee"
job_id = fields.Many2one('hr.job', 'Job title')

but when defining the field in the view

<field name="job_id"/> 

 I get  

"Error details:
Field `job_id` does not exist"

I created an inherited view of the original issue kanban view

<field name="inherit_id" ref="project_issue.project_issue_kanban_view"/> 


Where else should it be defined or what exactly am I missing here?
Help appreciated.


Avatar
Descartar
Mejor respuesta

Hi Oskar Must,

You are adding new field inside the employee table instead of project issue table.

Correct the model name in inherited class.

instead of

_inherit = 'hr.employee'  #wrong model used.

It must be:

_inherit = 'project.issue'  #This is correct model

As you have inherited the view of project.issue model.

This would be your code:

class project_issue(models.Model):
_inherit = "project.issue"
    job_id = fields.Many2one('hr.job', 'Job title')

 

Hope this would helps you.

Rgds,

Anil.



Avatar
Descartar
Mejor respuesta

Hi Oskar,

You are making wrong inheritence.

You should take inherit class name project.issue instead of hr.employee.

class hr_employee(models.Model):

_inherit = "hr.employee"

job_id = fields.Many2one('hr.job', 'Job title')

It will work

Avatar
Descartar
Autor Mejor respuesta

Hi Akhilesh & Anil, 

Thank you both, I got it working now :)

Much simpler than I expected too.

(Couldn't write this as a comment on your answers, not enough karma)

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
sept 15
47
3
abr 23
17738
1
mar 15
12186
2
nov 22
10170
1
may 21
6628