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.

61 lines
2.0 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.card_support",
  10. )
  11. task_type_default_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="beesdoo_shift.attendance_sheet_generation_interval",
  23. )
  24. @api.multi
  25. def set_values(self):
  26. super(ResConfigSettings, self).set_values()
  27. parameters = self.env["ir.config_parameter"].sudo()
  28. parameters.set_param(
  29. "beesdoo_shift.card_support", str(self.card_support),
  30. )
  31. parameters.set_param(
  32. "beesdoo_shift.task_type_default_id",
  33. str(self.task_type_default_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_values(self):
  41. res = super(ResConfigSettings, self).get_values()
  42. res.update(
  43. card_support=ast.literal_eval(
  44. self.env["ir.config_parameter"].get_param(
  45. "beesdoo_shift.card_support"
  46. ),
  47. ),
  48. task_type_default_id=int(
  49. self.env["ir.config_parameter"].get_param(
  50. "beesdoo_shift.task_type_default_id"
  51. )
  52. ),
  53. )
  54. return res