# -*- coding: utf-8 -*-

from odoo import api, fields, models, _


class HrEmployee(models.Model):
    _inherit = 'hr.employee'

    budgeted_hour_week = fields.Integer("Working days per week", default=5)

    @api.onchange('resource_calendar_id')
    def onchange_(self):
        if self.resource_calendar_id and self.resource_calendar_id.attendance_ids:
            total_week = [val.dayofweek for val in self.resource_calendar_id.attendance_ids]
            res = list(set(total_week))
            self.budgeted_hour_week = len(res)

class EmployeePublic(models.Model):
    _inherit = 'hr.employee.public'

    budgeted_hour_week = fields.Integer("Working days per week")
