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.

133 lines
5.3 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2019 - Today Coop IT Easy SCRLfs (<http://www.coopiteasy.be>)
  3. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  4. from datetime import date, datetime, timedelta
  5. from openerp.tests.common import TransactionCase
  6. class TestAttendanceSheet(TransactionCase):
  7. def setUp(self):
  8. super(TestAttendanceSheet, self).setUp()
  9. self.shift_model = self.env["beesdoo.shift.shift"]
  10. self.shift_template_model = self.env["beesdoo.shift.template"]
  11. self.attendance_sheet_model = self.env["beesdoo.shift.sheet"]
  12. self.current_time = datetime.now()
  13. self.user_admin = self.env.ref("base.partner_root")
  14. self.user_permanent = self.env.ref(
  15. "beesdoo_shift.beesdoo_shift_partner_2_demo"
  16. )
  17. self.user_generic = self.env.ref(
  18. "beesdoo_shift.beesdoo_shift_partner_1_demo"
  19. )
  20. self.worker_regular_1 = self.env.ref(
  21. "beesdoo_base.res_partner_cooperator_6_demo"
  22. )
  23. self.worker_regular_2 = self.env.ref(
  24. "beesdoo_base.res_partner_cooperator_5_demo"
  25. )
  26. self.worker_regular_3 = self.env.ref(
  27. "beesdoo_base.res_partner_cooperator_4_demo"
  28. )
  29. self.worker_regular_super_1 = self.env.ref(
  30. "beesdoo_base.res_partner_cooperator_1_demo"
  31. )
  32. self.worker_irregular_1 = self.env.ref(
  33. "beesdoo_base.res_partner_cooperator_2_demo"
  34. )
  35. self.worker_irregular_2 = self.env.ref(
  36. "beesdoo_base.res_partner_cooperator_4_demo"
  37. )
  38. self.task_type_1 = self.env.ref(
  39. "beesdoo_shift.beesdoo_shift_task_type_1_demo"
  40. )
  41. self.task_type_2 = self.env.ref(
  42. "beesdoo_shift.beesdoo_shift_task_type_2_demo"
  43. )
  44. self.task_type_3 = self.env.ref(
  45. "beesdoo_shift.beesdoo_shift_task_type_3_demo"
  46. )
  47. self.task_template_1 = self.env.ref(
  48. "beesdoo.shift.beesdoo_shift_task_template_1_demo"
  49. )
  50. self.task_template_2 = self.env.ref(
  51. "beesdoo.shift.beesdoo_shift_task_template_2_demo"
  52. )
  53. self.shift_regular_regular_1 = self.shift_model.create(
  54. {
  55. "task_template_id": self.task_template_1.id,
  56. "task_type_id": self.task_type_1.id,
  57. "worker_id": self.worker_regular_1.id,
  58. "start_time": self.current_time + timedelta(minutes=5),
  59. "end_time": self.current_time + timedelta(minutes=10),
  60. "is_regular": True,
  61. "is_compensation": False,
  62. }
  63. )
  64. self.shift_regular_regular_2 = self.shift_model.create(
  65. {
  66. "task_template_id": self.task_template_2.id,
  67. "task_type_id": self.task_type_2.id,
  68. "worker_id": self.worker_regular_2.id,
  69. "start_time": self.current_time - timedelta(minutes=50),
  70. "end_time": self.current_time - timedelta(minutes=20),
  71. "is_regular": True,
  72. "is_compensation": False,
  73. }
  74. )
  75. self.shift_regular_regular_replaced_1 = self.shift_model.create(
  76. {
  77. "task_template_id": self.task_template_1.id,
  78. "task_type_id": self.task_type_3.id,
  79. "worker_id": self.worker_regular_3.id,
  80. "start_time": self.current_time + timedelta(minutes=5),
  81. "end_time": self.current_time + timedelta(minutes=10),
  82. "is_regular": True,
  83. "is_compensation": False,
  84. "replaced_id": self.worker_regular_1.id,
  85. }
  86. )
  87. self.shift_regular_compensation_1 = self.shift_model.create(
  88. {
  89. "task_template_id": self.task_template_2.id,
  90. "task_type_id": self.task_type_1.id,
  91. "worker_id": self.worker_regular_super_1.id,
  92. "start_time": self.current_time + timedelta(minutes=9),
  93. "end_time": self.current_time + timedelta(minutes=21),
  94. "is_regular": False,
  95. "is_compensation": True,
  96. }
  97. )
  98. self.shift_irregular_1 = self.shift_model.create(
  99. {
  100. "task_template_id": self.task_template_1.id,
  101. "task_type_id": self.task_type_2.id,
  102. "worker_id": self.worker_irregular_1.id,
  103. "start_time": self.current_time + timedelta(minutes=5),
  104. "end_time": self.current_time + timedelta(minutes=10),
  105. }
  106. )
  107. self.shift_irregular_2 = self.shift_model.create(
  108. {
  109. "task_template_id": self.task_template_2.id,
  110. "task_type_id": self.task_type_3.id,
  111. "worker_id": self.worker_irregular_2.id,
  112. "start_time": self.current_time + timedelta(minutes=40),
  113. "end_time": self.current_time + timedelta(minutes=50),
  114. }
  115. )
  116. self.shift_empty_1 = self.shift_model.create(
  117. {
  118. "task_template_id": self.task_template_1.id,
  119. "task_type_id": self.task_type_1.id,
  120. "start_time": self.current_time + timedelta(minutes=5),
  121. "end_time": self.current_time + timedelta(minutes=10),
  122. }
  123. )