res_config_settings.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from odoo import api, fields, models
  4. class ResConfigSettings(models.TransientModel):
  5. _inherit = 'res.config.settings'
  6. group_attendance_use_pin = fields.Boolean(
  7. string='Employee PIN',
  8. implied_group="hr_attendance.group_hr_attendance_use_pin")
  9. hr_attendance_overtime = fields.Boolean(
  10. string="Count Extra Hours", readonly=False)
  11. overtime_start_date = fields.Date(string="Extra Hours Starting Date", readonly=False)
  12. overtime_company_threshold = fields.Integer(
  13. string="Tolerance Time In Favor Of Company", readonly=False)
  14. overtime_employee_threshold = fields.Integer(
  15. string="Tolerance Time In Favor Of Employee", readonly=False)
  16. attendance_kiosk_mode = fields.Selection(related='company_id.attendance_kiosk_mode', readonly=False)
  17. attendance_barcode_source = fields.Selection(related='company_id.attendance_barcode_source', readonly=False)
  18. attendance_kiosk_delay = fields.Integer(related='company_id.attendance_kiosk_delay', readonly=False)
  19. @api.model
  20. def get_values(self):
  21. res = super(ResConfigSettings, self).get_values()
  22. company = self.env.company
  23. res.update({
  24. 'hr_attendance_overtime': company.hr_attendance_overtime,
  25. 'overtime_start_date': company.overtime_start_date,
  26. 'overtime_company_threshold': company.overtime_company_threshold,
  27. 'overtime_employee_threshold': company.overtime_employee_threshold,
  28. })
  29. return res
  30. def set_values(self):
  31. super().set_values()
  32. company = self.env.company
  33. # Done this way to have all the values written at the same time,
  34. # to avoid recomputing the overtimes several times with
  35. # invalid company configurations
  36. fields_to_check = [
  37. 'hr_attendance_overtime',
  38. 'overtime_start_date',
  39. 'overtime_company_threshold',
  40. 'overtime_employee_threshold',
  41. ]
  42. if any(self[field] != company[field] for field in fields_to_check):
  43. company.write({field: self[field] for field in fields_to_check})