This question has been flagged
3 Replies
4847 Views

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
Discard
Best Answer

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
Discard
Best Answer

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
Discard
Author Best Answer

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
Discard