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.

75 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. import ast
  5. from openerp import fields, models, api
  6. class ShiftConfigSettings(models.TransientModel):
  7. _name = "beesdoo.shift.config.settings"
  8. _inherit = "res.config.settings"
  9. card_support = fields.Boolean(
  10. string="Scan cooperators cards instead of login for sheets validation",
  11. default=False,
  12. )
  13. default_task_type_id = fields.Many2one(
  14. "beesdoo.shift.type",
  15. string="Default Task Type",
  16. help="Default task type for attendance sheet pre-filling",
  17. required=True,
  18. )
  19. attendance_sheet_generation_interval = fields.Integer(
  20. string="Time interval for attendance sheet generation",
  21. help="Time interval expressed in minutes",
  22. required=True,
  23. )
  24. @api.multi
  25. def set_params(self):
  26. self.ensure_one()
  27. parameters = self.env["ir.config_parameter"]
  28. parameters.set_param(
  29. "beesdoo_shift.card_support", str(self.card_support),
  30. )
  31. parameters.set_param(
  32. "beesdoo_shift.default_task_type_id",
  33. str(self.default_task_type_id.id),
  34. )
  35. parameters.set_param(
  36. "beesdoo_shift.attendance_sheet_generation_interval",
  37. str(self.attendance_sheet_generation_interval),
  38. )
  39. @api.multi
  40. def get_default_card_support(self):
  41. return {
  42. "card_support": ast.literal_eval(
  43. self.env["ir.config_parameter"].get_param(
  44. "beesdoo_shift.card_support"
  45. )
  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. }