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. # 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 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": ast.literal_eval(
  42. self.env["ir.config_parameter"].get_param(
  43. "beesdoo_shift.card_support"
  44. )
  45. )
  46. }
  47. @api.multi
  48. def get_default_task_type_id(self):
  49. return {
  50. "default_task_type_id": int(
  51. self.env["ir.config_parameter"].get_param(
  52. "beesdoo_shift.default_task_type_id"
  53. )
  54. )
  55. }
  56. @api.multi
  57. def get_default_attendance_sheet_generation_interval(self):
  58. return {
  59. "attendance_sheet_generation_interval": int(
  60. self.env["ir.config_parameter"].get_param(
  61. "beesdoo_shift.attendance_sheet_generation_interval"
  62. )
  63. )
  64. }