Files
odoo_source/addons/hr_attendance/models/res_config_settings.py
T
Kevin Baptiste 9e6d2da504 [IMP] hr_attendance: compute overtime on attendances
This commit adds a new model `hr.attendance.overtime`.

When an employee checks out, an overtime entry will be created when:
    - the option is enabled on the company;
    - the employee worked more or less than the number of hours they
    were supposed to work that day.

TaskID: 1904850
2021-07-06 11:35:01 +02:00

47 lines
1.9 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
group_attendance_use_pin = fields.Boolean(
string='Employee PIN',
implied_group="hr_attendance.group_hr_attendance_use_pin")
hr_attendance_overtime = fields.Boolean(
string="Count Extra Hours", readonly=False)
overtime_start_date = fields.Date(string="Extra Hours Starting Date", readonly=False)
overtime_company_threshold = fields.Integer(
string="Tolerance Time In Favor Of Company", readonly=False)
overtime_employee_threshold = fields.Integer(
string="Tolerance Time In Favor Of Employee", readonly=False)
@api.model
def get_values(self):
res = super(ResConfigSettings, self).get_values()
company = self.env.company
res.update({
'hr_attendance_overtime': company.hr_attendance_overtime,
'overtime_start_date': company.overtime_start_date,
'overtime_company_threshold': company.overtime_company_threshold,
'overtime_employee_threshold': company.overtime_employee_threshold,
})
return res
def set_values(self):
super(ResConfigSettings, self).set_values()
company = self.env.company
# Done this way to have all the values written at the same time,
# to avoid recomputing the overtimes several times with
# invalid company configurations
fields_to_check = [
'hr_attendance_overtime',
'overtime_start_date',
'overtime_company_threshold',
'overtime_employee_threshold',
]
if any(self[field] != company[field] for field in fields_to_check):
company.write({field: self[field] for field in fields_to_check})