From 7f5166aad8f40851fb088dbfcb3d166df86b3e51 Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Sun, 7 Oct 2018 22:35:15 +0200 Subject: [PATCH] [TASK 48l] take irregular worker holidays into account: Don't change counterduring cron when they are on holidays --- beesdoo_shift/models/cooperative_status.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/beesdoo_shift/models/cooperative_status.py b/beesdoo_shift/models/cooperative_status.py index f6ca088..76e2a3d 100644 --- a/beesdoo_shift/models/cooperative_status.py +++ b/beesdoo_shift/models/cooperative_status.py @@ -274,8 +274,16 @@ class CooperativeStatus(models.Model): journal = self.env['beesdoo.shift.journal'].search([('date', '=', today)]) if not journal: journal = self.env['beesdoo.shift.journal'].create({'date': today}) - - irregular = self.search([('status', '!=', 'unsubscribed'), ('working_mode', '=', 'irregular'), ('irregular_start_date', '!=', False)]) + domain = ['&', + '&', + '&', ('status', '!=', 'unsubscribed'), + ('working_mode', '=', 'irregular'), + ('irregular_start_date', '!=', False), + '|', + '|', ('holiday_start_time', '=', False), ('holiday_end_time', '=', False), + '|', ('holiday_start_time', '>', today), ('holiday_end_time', '<', today), + ] + irregular = self.search(domain) today_date = fields.Date.from_string(today) for status in irregular: if status.status == 'exempted':