I have a requirement that want to fulfill is bringing a value from the database and display in the UI, we have a app which we can assign "projects" to many people so i have to display in the persons information a field with the project currently assigned to him/her.
I was thinking about creating a function to retrieve that data using the "search()" method to fetch the field needed.
#for the moment i have added the variable in the class
project_name = fields.Char('Project Name', compute='_compute_get_employee_project')
#this is the function i am building (trying)
@api.model
def _compute_get_employee_project(self):
#verify the employee belongs to a project
employee_task = self.env['project.task'].search([('user_id','=',self.user_id.id),('status','=','assigned')],limit=1)
employee_project = self.env['project.project'].search([('id', '=', employee_task.project_id.id)], limit=1)
Thank you for your time!!