diff --git a/beesdoo_shift/i18n/fr.po b/beesdoo_shift/i18n/fr.po
index 4cd3424..8779f0b 100644
--- a/beesdoo_shift/i18n/fr.po
+++ b/beesdoo_shift/i18n/fr.po
@@ -1692,12 +1692,12 @@ msgid "Replaced id"
msgstr "Id du remplaçant"
#. module: beesdoo_shift
-#: model:ir.model.fields,field_description:beesdoo_shift.field_beesdoo_shift_sheet_expected_replacement_worker_id
+#: model:ir.model.fields,field_description:beesdoo_shift.field_beesdoo_shift_sheet_expected_replaced_id
msgid "Replacement Worker"
msgstr "Travailleur remplaçant"
#. module: beesdoo_shift
-#: model:ir.model.fields,help:beesdoo_shift.field_beesdoo_shift_sheet_expected_replacement_worker_id
+#: model:ir.model.fields,help:beesdoo_shift.field_beesdoo_shift_sheet_expected_replaced_id
msgid "Replacement Worker (must be regular)"
msgstr "Travailleur remplaçant (doit être régulier)"
diff --git a/beesdoo_shift/i18n/fr_BE.po b/beesdoo_shift/i18n/fr_BE.po
index 4cd3424..8779f0b 100644
--- a/beesdoo_shift/i18n/fr_BE.po
+++ b/beesdoo_shift/i18n/fr_BE.po
@@ -1692,12 +1692,12 @@ msgid "Replaced id"
msgstr "Id du remplaçant"
#. module: beesdoo_shift
-#: model:ir.model.fields,field_description:beesdoo_shift.field_beesdoo_shift_sheet_expected_replacement_worker_id
+#: model:ir.model.fields,field_description:beesdoo_shift.field_beesdoo_shift_sheet_expected_replaced_id
msgid "Replacement Worker"
msgstr "Travailleur remplaçant"
#. module: beesdoo_shift
-#: model:ir.model.fields,help:beesdoo_shift.field_beesdoo_shift_sheet_expected_replacement_worker_id
+#: model:ir.model.fields,help:beesdoo_shift.field_beesdoo_shift_sheet_expected_replaced_id
msgid "Replacement Worker (must be regular)"
msgstr "Travailleur remplaçant (doit être régulier)"
diff --git a/beesdoo_shift/i18n/nl_BE.po b/beesdoo_shift/i18n/nl_BE.po
index 1644432..879c8ea 100644
--- a/beesdoo_shift/i18n/nl_BE.po
+++ b/beesdoo_shift/i18n/nl_BE.po
@@ -1696,12 +1696,12 @@ msgid "Replaced id"
msgstr "Replaced id"
#. module: beesdoo_shift
-#: model:ir.model.fields,field_description:beesdoo_shift.field_beesdoo_shift_sheet_expected_replacement_worker_id
+#: model:ir.model.fields,field_description:beesdoo_shift.field_beesdoo_shift_sheet_expected_replaced_id
msgid "Replacement Worker"
msgstr "Vervangingswerker"
#. module: beesdoo_shift
-#: model:ir.model.fields,help:beesdoo_shift.field_beesdoo_shift_sheet_expected_replacement_worker_id
+#: model:ir.model.fields,help:beesdoo_shift.field_beesdoo_shift_sheet_expected_replaced_id
msgid "Replacement Worker (must be regular)"
msgstr "Vervangingswerker (regelmatig werkregime vereist)"
diff --git a/beesdoo_shift/models/__init__.py b/beesdoo_shift/models/__init__.py
index ece8050..f3e2a19 100644
--- a/beesdoo_shift/models/__init__.py
+++ b/beesdoo_shift/models/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
+import task
import attendance_sheet
import planning
import res_config
-import task
import cooperative_status
diff --git a/beesdoo_shift/models/attendance_sheet.py b/beesdoo_shift/models/attendance_sheet.py
index 4794ec8..1c72094 100644
--- a/beesdoo_shift/models/attendance_sheet.py
+++ b/beesdoo_shift/models/attendance_sheet.py
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
-import unittest
-
from datetime import date, datetime, timedelta
from lxml import etree
@@ -18,7 +16,11 @@ class AttendanceSheetShift(models.AbstractModel):
@api.model
def default_task_type_id(self):
parameters = self.env["ir.config_parameter"]
- id = int(parameters.get_param("beesdoo_shift.default_task_type_id", default=1))
+ id = int(
+ parameters.get_param(
+ "beesdoo_shift.default_task_type_id", default=1
+ )
+ )
task_types = self.env["beesdoo.shift.type"]
return task_types.browse(id)
@@ -31,7 +33,12 @@ class AttendanceSheetShift(models.AbstractModel):
ondelete="cascade",
)
state = fields.Selection(
- [("done", "Present"), ("absent", "Absent"),],
+ [
+ ("done", "Present"),
+ ("absent_0", "Absent - 0 Compensation"),
+ ("absent_1", "Absent - 1 Compensation"),
+ ("absent_2", "Absent - 2 Compensations"),
+ ],
string="Shift State",
required=True,
)
@@ -60,7 +67,7 @@ class AttendanceSheetShift(models.AbstractModel):
class AttendanceSheetShiftExpected(models.Model):
"""
- Already existing shifts on sheet creation.
+ Shifts already expected.
"""
_name = "beesdoo.shift.sheet.expected"
@@ -70,10 +77,7 @@ class AttendanceSheetShiftExpected(models.Model):
super_coop_id = fields.Many2one(
related="task_id.super_coop_id", store=True
)
- compensation_no = fields.Selection(
- [("0", "0"), ("1", "1"), ("2", "2"),], string="Compensations",
- )
- replacement_worker_id = fields.Many2one(
+ replaced_id = fields.Many2one(
"res.partner",
string="Replacement Worker",
help="Replacement Worker (must be regular)",
@@ -84,29 +88,15 @@ class AttendanceSheetShiftExpected(models.Model):
],
)
- @api.onchange("replacement_worker_id")
+ @api.onchange("replaced_id")
def on_change_replacement_worker(self):
- if self.replacement_worker_id:
+ if self.replaced_id:
self.state = "done"
- @api.onchange("state")
- def on_change_state(self):
- if not self.state or self.state == "done":
- self.compensation_no = False
- if self.state == "absent":
- self.compensation_no = "2"
-
- @api.constrains("state", "compensation_no")
- def _constrain_compensation_no(self):
- if self.state == "absent":
- if not self.compensation_no:
- raise UserError(_("A compensation number is required"))
-
class AttendanceSheetShiftAdded(models.Model):
"""
- Not already registered shifts.
- Added shifts are necessarily 'Present'
+ Shifts added during time slot.
"""
_name = "beesdoo.shift.sheet.added"
@@ -178,7 +168,11 @@ class AttendanceSheet(models.Model):
readonly=True,
help="Indicative maximum number of workers.",
)
- notes = fields.Text("Notes", default="", help="Notes about the attendance for the Members Office")
+ notes = fields.Text(
+ "Notes",
+ default="",
+ help="Notes about the attendance for the Members Office",
+ )
is_annotated = fields.Boolean(
compute="_compute_is_annotated",
string="Is annotated",
@@ -293,9 +287,9 @@ class AttendanceSheet(models.Model):
added_ids = [s.worker_id.id for s in self.added_shift_ids]
expected_ids = [s.worker_id.id for s in self.expected_shift_ids]
replacement_ids = [
- s.replacement_worker_id.id
+ s.replaced_id.id
for s in self.expected_shift_ids
- if s.replacement_worker_id.id
+ if s.replaced_id.id
]
ids = added_ids + expected_ids + replacement_ids
@@ -326,6 +320,7 @@ class AttendanceSheet(models.Model):
)
worker = self.env["res.partner"].search([("barcode", "=", barcode)])
+
if not len(worker):
raise UserError(
_(
@@ -372,11 +367,11 @@ class AttendanceSheet(models.Model):
for id in self.expected_shift_ids.ids:
shift = self.env["beesdoo.shift.sheet.expected"].browse(id)
if (
- shift.worker_id == worker and not shift.replacement_worker_id
- ) or shift.replacement_worker_id == worker:
+ shift.worker_id == worker and not shift.replaced_id
+ ) or shift.replaced_id == worker:
shift.state = "done"
return
- if shift.worker_id == worker and shift.replacement_worker_id:
+ if shift.worker_id == worker and shift.replaced_id:
raise UserError(
_("%s was expected as replaced.") % worker.name
)
@@ -427,10 +422,9 @@ class AttendanceSheet(models.Model):
"attendance_sheet_id": new_sheet.id,
"task_id": task.id,
"worker_id": task.worker_id.id,
- "replacement_worker_id": task.replaced_id.id,
+ "replaced_id": task.replaced_id.id,
"task_type_id": task.task_type_id.id,
- "state": "absent",
- "compensation_no": "2",
+ "state": "absent_2",
"working_mode": task.working_mode,
"is_compensation": task.is_compensation,
}
@@ -464,19 +458,10 @@ class AttendanceSheet(models.Model):
# Expected shifts status update
for expected_shift in self.expected_shift_ids:
actual_shift = expected_shift.task_id
- # Merge state with compensations number to fit Task model
- if (
- expected_shift.state == "absent"
- and expected_shift.compensation_no
- ):
- state_converted = "absent_%s" % expected_shift.compensation_no
- else:
- state_converted = expected_shift.state
-
- actual_shift.replaced_id = expected_shift.replacement_worker_id
- actual_shift.state = state_converted
+ actual_shift.replaced_id = expected_shift.replaced_id
+ actual_shift.state = expected_shift.state
- if expected_shift.state == "absent":
+ if expected_shift.state != "done":
mail_template = self.env.ref(
"beesdoo_shift.email_template_non_attendance", False
)
@@ -523,10 +508,8 @@ class AttendanceSheet(models.Model):
{
"state": added_shift.state,
"worker_id": added_shift.worker_id.id,
- "is_regular": not is_compensation
- and is_regular_worker,
- "is_compensation": is_compensation
- and is_regular_worker,
+ "is_regular": not is_compensation and is_regular_worker,
+ "is_compensation": is_compensation and is_regular_worker,
}
)
added_shift.task_id = actual_shift.id
@@ -544,7 +527,9 @@ class AttendanceSheet(models.Model):
raise UserError(_("The sheet has already been validated."))
if start_time_dt > datetime.now():
raise UserError(
- _("Attendance sheet can only be validated once the shifts have started.")
+ _(
+ "Attendance sheet can only be validated once the shifts have started."
+ )
)
# Fields validation
diff --git a/beesdoo_shift/security/ir.model.access.csv b/beesdoo_shift/security/ir.model.access.csv
index e99c766..54c57d2 100644
--- a/beesdoo_shift/security/ir.model.access.csv
+++ b/beesdoo_shift/security/ir.model.access.csv
@@ -2,6 +2,7 @@ id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
create_beesdoo_shift_shift,create_edit_beesdoo_shift_shift,model_beesdoo_shift_shift,group_shift_attendance_sheet,1,1,1,0
read_beesdoo_shift_sheet_shift,read_beesdoo_shift_sheet_shift,model_beesdoo_shift_sheet_shift,group_shift_attendance_sheet,1,0,0,0
+create_beesdoo_shift_sheet_shift,create_beesdoo_shift_sheet_shift,model_beesdoo_shift_sheet_shift,group_shift_attendance_sheet,1,1,1,0
create_beesdoo_shift_sheet_expected,create_beesdoo_shift_sheet_expected,model_beesdoo_shift_sheet_expected,group_shift_attendance_sheet,1,1,1,0
manage_beesdoo_shift_sheet_added,manage_beesdoo_shift_sheet_added,model_beesdoo_shift_sheet_added,group_shift_attendance_sheet,1,1,1,1
create_beesdoo_shift_sheet,create_beesdoo_shift_sheet,model_beesdoo_shift_sheet,group_shift_attendance_sheet,1,1,1,0
diff --git a/beesdoo_shift/tests/test_beesdoo_shift.py b/beesdoo_shift/tests/test_beesdoo_shift.py
index 7c1cbb2..78d827a 100644
--- a/beesdoo_shift/tests/test_beesdoo_shift.py
+++ b/beesdoo_shift/tests/test_beesdoo_shift.py
@@ -228,15 +228,14 @@ class TestBeesdooShift(TransactionCase):
for shift in sheet_1.expected_shift_ids:
self.assertEquals(shift.worker_id, shift.task_id.worker_id)
self.assertEquals(
- shift.replacement_worker_id, shift.task_id.replaced_id
+ shift.replaced_id, shift.task_id.replaced_id
)
self.assertEquals(shift.task_type_id, shift.task_id.task_type_id)
self.assertEquals(shift.super_coop_id, shift.task_id.super_coop_id)
self.assertEquals(shift.working_mode, shift.task_id.working_mode)
# Status should be "absent" for all shifts
- self.assertEquals(shift.state, "absent")
- self.assertEquals(shift.compensation_no, "2")
+ self.assertEquals(shift.state, "absent_2")
# Empty shift should be considered in max worker number calculation
self.assertEquals(sheet_1.max_worker_no, 4)
@@ -333,8 +332,7 @@ class TestBeesdooShift(TransactionCase):
# Expected shifts edition
sheet_1.expected_shift_ids[1].state = "done"
- sheet_1.expected_shift_ids[1].compensation_no = False
- sheet_1.expected_shift_ids[2].compensation_no = "1"
+ sheet_1.expected_shift_ids[2].state = "absent_1"
# Added shits addition
sheet_1.added_shift_ids |= sheet_1.added_shift_ids.new(
@@ -411,7 +409,7 @@ class TestBeesdooShift(TransactionCase):
)
# sheet_1.expected_shift_ids[0].worker_id
- # sheet_1.expected_shift_ids[2].replacement_worker_id
+ # sheet_1.expected_shift_ids[2].replaced_id
def test_shift_counters(self):
"Test shift counters calculation and cooperative status update"
diff --git a/beesdoo_shift/views/attendance_sheet.xml b/beesdoo_shift/views/attendance_sheet.xml
index becea88..40879c3 100644
--- a/beesdoo_shift/views/attendance_sheet.xml
+++ b/beesdoo_shift/views/attendance_sheet.xml
@@ -34,23 +34,17 @@
beesdoo.shift.sheet.expected
-
-
@@ -85,7 +79,7 @@
-
+