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.

74 lines
2.2 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2019-2020 Elouan Le Bars <elouan@coopiteasy.be>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from openerp import fields, models, api
  5. class ShiftConfigSettings(models.TransientModel):
  6. _name = "beesdoo.shift.config.settings"
  7. _inherit = "res.config.settings"
  8. card_support = fields.Boolean(
  9. string="Scan cooperators cards instead of login for sheets validation",
  10. default=False
  11. )
  12. default_task_type_id = fields.Many2one(
  13. "beesdoo.shift.type",
  14. string="Default Task Type",
  15. help="Default task type for attendance sheet pre-filling",
  16. required=True,
  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. )
  23. @api.multi
  24. def set_params(self):
  25. self.ensure_one()
  26. parameters = self.env["ir.config_parameter"]
  27. parameters.set_param(
  28. "beesdoo_shift.card_support", str(self.card_support),
  29. )
  30. parameters.set_param(
  31. "beesdoo_shift.default_task_type_id",
  32. str(self.default_task_type_id.id),
  33. )
  34. parameters.set_param(
  35. "beesdoo_shift.attendance_sheet_generation_interval",
  36. str(self.attendance_sheet_generation_interval),
  37. )
  38. @api.multi
  39. def get_default_card_support(self):
  40. return {
  41. "card_support": (
  42. self.env["ir.config_parameter"].get_param(
  43. "beesdoo_shift.card_support"
  44. )
  45. == "True"
  46. )
  47. }
  48. @api.multi
  49. def get_default_task_type_id(self):
  50. return {
  51. "default_task_type_id": int(
  52. self.env["ir.config_parameter"].get_param(
  53. "beesdoo_shift.default_task_type_id"
  54. )
  55. )
  56. }
  57. @api.multi
  58. def get_default_attendance_sheet_generation_interval(self):
  59. return {
  60. "attendance_sheet_generation_interval": int(
  61. self.env["ir.config_parameter"].get_param(
  62. "beesdoo_shift.attendance_sheet_generation_interval"
  63. )
  64. )
  65. }