# See LICENSE file for full copyright and licensing details.

from odoo import api, fields, models


class ProjectProject(models.Model):
    _inherit = 'project.project'

    team_members_line = fields.One2many('prime.project.team.member', 'project_id', string='Team Members')

class PrimeProjectTeamMember(models.Model):
    _name = 'prime.project.team.member'

    project_id = fields.Many2one('project.project', "Project")
    user_id = fields.Many2one('res.users', "User")
    employee_id = fields.Many2one('hr.employee',string='Employee', compute='_compute_employee_id', store=True)
    department_id = fields.Many2one('hr.department',string='Department',related='employee_id.department_id', store=True)
    image = fields.Binary(
        string='Photo',related='employee_id.image_1920', store=True)

    @api.depends('user_id')
    def _compute_employee_id(self):
        print("COMPUTE CURRENT MANAGER::::::::::::::::::::::::::")
        employee_id = False
        if self.user_id:
            employee = self.env['hr.employee'].search([('user_id','=',self.user_id.id)],limit=1)
            for emp in employee:
                employee_id = emp.id
            self.employee_id = employee_id

