|
@ -277,20 +277,21 @@ class AttendanceSheet(models.Model): |
|
|
|
|
|
|
|
|
@api.constrains("expected_shift_ids", "added_shift_ids") |
|
|
@api.constrains("expected_shift_ids", "added_shift_ids") |
|
|
def _constrain_unique_worker(self): |
|
|
def _constrain_unique_worker(self): |
|
|
return |
|
|
|
|
|
# Warning : map return generator in python3 (for Odoo 12) |
|
|
# Warning : map return generator in python3 (for Odoo 12) |
|
|
# added_workers_ids = map(lambda s: s.worker_id.id, self.added_shift_ids) |
|
|
|
|
|
# expected_workers_ids = map(lambda s: s.worker_id.id, self.expected_shift_ids) |
|
|
|
|
|
# replacement_workers_ids = map(lambda s: s.replacement_worker_id.id, self.expected_shift_ids) |
|
|
|
|
|
# ids = (added_workers_ids + expected_workers_ids + replacement_workers_ids) |
|
|
|
|
|
|
|
|
added_ids = map(lambda s: s.worker_id.id, self.added_shift_ids) |
|
|
|
|
|
expected_ids = map(lambda s: s.worker_id.id, self.expected_shift_ids) |
|
|
|
|
|
replacement_ids = map( |
|
|
|
|
|
lambda s: s.replacement_worker_id.id, self.expected_shift_ids |
|
|
|
|
|
) |
|
|
|
|
|
replacement_ids = filter(bool, replacement_ids) |
|
|
|
|
|
ids = added_ids + expected_ids + replacement_ids |
|
|
|
|
|
|
|
|
# if len(ids) - len(set(ids)): |
|
|
|
|
|
# raise UserError("You can't add the same worker more than once.") |
|
|
|
|
|
|
|
|
if (len(ids) - len(set(ids))) > 0: |
|
|
|
|
|
raise UserError("You can't add the same worker more than once to an attendance sheet.") |
|
|
|
|
|
|
|
|
@api.depends("added_shift_ids") |
|
|
@api.depends("added_shift_ids") |
|
|
def _compute_added_shift_nb(self): |
|
|
def _compute_added_shift_nb(self): |
|
|
self.added_worker_nb = len(self.added_shift_ids) |
|
|
self.added_worker_nb = len(self.added_shift_ids) |
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
# Compute name (not hardcorded to prevent incoherence with timezone) |
|
|
# Compute name (not hardcorded to prevent incoherence with timezone) |
|
|
@api.depends("start_time", "end_time") |
|
|
@api.depends("start_time", "end_time") |
|
|