You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.1 KiB

  1. # Copyright 2019-2020 Elouan Le Bars <elouan@coopiteasy.be>
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. import ast
  4. from odoo import fields, models, api
  5. class ResConfigSettings(models.TransientModel):
  6. _inherit = "res.config.settings"
  7. card_support = fields.Boolean(
  8. string="Scan cooperators cards instead of login for sheets validation",
  9. config_parameter="beesdoo_shift_attendance.card_support",
  10. )
  11. pre_filled_task_type_id = fields.Many2one(
  12. "beesdoo.shift.type",
  13. string="Default Task Type",
  14. help="Default task type for attendance sheet pre-filling",
  15. required=True,
  16. default=False,
  17. )
  18. attendance_sheet_generation_interval = fields.Integer(
  19. string="Time interval for attendance sheet generation",
  20. help="Time interval expressed in minutes",
  21. required=True,
  22. config_parameter=(
  23. "beesdoo_shift_attendance.attendance_sheet_generation_interval"
  24. ),
  25. )
  26. @api.multi
  27. def set_values(self):
  28. super(ResConfigSettings, self).set_values()
  29. parameters = self.env["ir.config_parameter"].sudo()
  30. parameters.set_param(
  31. "beesdoo_shift_attendance.card_support", str(self.card_support),
  32. )
  33. parameters.set_param(
  34. "beesdoo_shift_attendance.pre_filled_task_type_id",
  35. str(self.pre_filled_task_type_id.id),
  36. )
  37. parameters.set_param(
  38. "beesdoo_shift_attendance.attendance_sheet_generation_interval",
  39. str(self.attendance_sheet_generation_interval),
  40. )
  41. @api.multi
  42. def get_values(self):
  43. res = super(ResConfigSettings, self).get_values()
  44. res.update(
  45. card_support=ast.literal_eval(
  46. self.env["ir.config_parameter"].get_param(
  47. "beesdoo_shift_attendance.card_support"
  48. ),
  49. ),
  50. pre_filled_task_type_id=int(
  51. self.env["ir.config_parameter"].get_param(
  52. "beesdoo_shift_attendance.pre_filled_task_type_id"
  53. )
  54. ),
  55. )
  56. return res