Browse Source

[FIX] b_shift_attendance

pull/133/head
Rémy Taymans 5 years ago
parent
commit
c9de5d9457
  1. 6
      beesdoo_shift_attendance/models/attendance_sheet.py
  2. 1
      beesdoo_shift_attendance/security/group.xml
  3. 29
      beesdoo_shift_attendance/tests/test_beesdoo_shift.py

6
beesdoo_shift_attendance/models/attendance_sheet.py

@ -527,7 +527,6 @@ class AttendanceSheet(models.Model):
def validate_with_checks(self):
self.ensure_one()
if self.state == "validated":
raise UserError(_("The sheet has already been validated."))
if self.start_time > datetime.now():
@ -606,7 +605,6 @@ class AttendanceSheet(models.Model):
Generate sheets with shifts in the time interval
defined from corresponding CRON time interval.
"""
tasks = self.env["beesdoo.shift.shift"]
sheets = self.env["beesdoo.shift.sheet"]
current_time = datetime.now()
@ -620,8 +618,8 @@ class AttendanceSheet(models.Model):
tasks = tasks.search(
[
("start_time", ">", str(current_time),),
("start_time", "<", str(current_time + allowed_time_range),),
("start_time", ">", str(current_time)),
("start_time", "<", str(current_time + allowed_time_range)),
]
)

1
beesdoo_shift_attendance/security/group.xml

@ -7,6 +7,7 @@
<field name="name">Attendance Sheet Validation</field>
<field name="category_id" ref="base.module_category_cooperative_management"/>
<field name="implied_ids" eval="[(4, ref('group_shift_attendance_sheet'))]"/>
<field name="users" eval="[(6, 0, [ref('base.user_root')])]" />
</record>
<record id="beesdoo_shift.group_shift_attendance" model="res.groups">
<field name="implied_ids" eval="[(4, ref('group_shift_attendance_sheet'))]"/>

29
beesdoo_shift_attendance/tests/test_beesdoo_shift.py

@ -57,23 +57,22 @@ class TestBeesdooShift(TransactionCase):
)
self.task_type_1 = self.env.ref(
"beesdoo_shift_attendance"
".beesdoo_shift_attendance_task_type_1_demo"
"beesdoo_shift.beesdoo_shift_task_type_1_demo"
)
self.task_type_2 = self.env.ref(
"beesdoo_shift_attendance"
".beesdoo_shift_attendance_task_type_2_demo"
"beesdoo_shift.beesdoo_shift_task_type_2_demo"
)
self.task_type_3 = self.env.ref(
"beesdoo_shift_attendance"
".beesdoo_shift_attendance_task_type_3_demo"
"beesdoo_shift.beesdoo_shift_task_type_3_demo"
)
self.task_template_1 = self.env.ref(
"beesdoo_shift.beesdoo_shift_task_template_1_demo"
"beesdoo_shift_attendance"
".beesdoo_shift_attendance_task_template_1_demo"
)
self.task_template_2 = self.env.ref(
"beesdoo_shift.beesdoo_shift_task_template_2_demo"
"beesdoo_shift_attendance"
".beesdoo_shift_attendance_task_template_2_demo"
)
# Set time in and out of generation interval parameter
@ -292,16 +291,16 @@ class TestBeesdooShift(TransactionCase):
self.assertFalse(shift.is_compensation)
# Add a worker that should be replaced
with self.assertRaises(UserError) as e:
with self.assertRaises(UserError):
sheet_1.on_barcode_scanned(421457731742)
# Wrong barcode
with self.assertRaises(UserError) as e:
with self.assertRaises(UserError):
sheet_1.on_barcode_scanned(101010)
# Add an unsubscribed worker
self.worker_regular_1.cooperative_status_ids.sr = -2
self.worker_regular_1.cooperative_status_ids.sc = -2
with self.assertRaises(UserError) as e:
with self.assertRaises(UserError):
sheet_1.on_barcode_scanned(421457731745)
def test_attendance_sheet_edition(self):
@ -351,9 +350,9 @@ class TestBeesdooShift(TransactionCase):
# Wait necessary time for shifts to begin
waiting_time = (self.start_in_1 - datetime.now()).total_seconds()
if waiting_time > 0:
with self.assertRaises(UserError) as e:
with self.assertRaises(UserError) as econtext:
sheet_1.validate_with_checks()
self.assertIn("wait", str(e.exception))
self.assertIn("once the shifts have started", str(econtext.exception))
time.sleep(waiting_time)
sheet_1.worker_nb_feedback = "enough"
@ -362,9 +361,9 @@ class TestBeesdooShift(TransactionCase):
sheet_1.validate_with_checks()
with self.assertRaises(UserError) as e:
with self.assertRaises(UserError) as econtext:
sheet_1.validate_with_checks()
self.assertIn("already been validated", str(e.exception))
self.assertIn("already been validated", str(econtext.exception))
self.assertEqual(sheet_1.state, "validated")
self.assertEqual(sheet_1.validated_by, self.user_admin.partner_id)

Loading…
Cancel
Save