From 3df4d3980ea0816315820b40b5982c5c612001d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Taymans?= Date: Tue, 7 Apr 2020 19:25:11 +0200 Subject: [PATCH] [FIX] beesdoo_shift: Next countdown infinite loop --- beesdoo_shift/__openerp__.py | 2 +- beesdoo_shift/models/cooperative_status.py | 46 +++++++++++++--------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/beesdoo_shift/__openerp__.py b/beesdoo_shift/__openerp__.py index d972307..ab05489 100644 --- a/beesdoo_shift/__openerp__.py +++ b/beesdoo_shift/__openerp__.py @@ -13,7 +13,7 @@ 'website': "https://github.com/beescoop/Obeesdoo", 'category': 'Cooperative management', - 'version': '9.0.1.3.0', + 'version': '9.0.1.3.1', 'depends': ['beesdoo_base', 'barcodes'], diff --git a/beesdoo_shift/models/cooperative_status.py b/beesdoo_shift/models/cooperative_status.py index 364f947..dde0202 100644 --- a/beesdoo_shift/models/cooperative_status.py +++ b/beesdoo_shift/models/cooperative_status.py @@ -151,18 +151,24 @@ class CooperativeStatus(models.Model): rec.irregular_start_date, date ) # Check holidays - if (rec.holiday_start_time and rec.holiday_end_time - and date >= rec.holiday_start_time - and date <= rec.holiday_end_time): + if ( + rec.holiday_start_time and rec.holiday_end_time + and date >= rec.holiday_start_time + and date <= rec.holiday_end_time + ): + date = add_days_delta(date, 1) continue # Check temporary exemption - elif (rec.temporary_exempt_start_date - and rec.temporary_exempt_end_date - and date >= rec.temporary_exempt_start_date - and date <= rec.temporary_exempt_end_date): + if ( + rec.temporary_exempt_start_date + and rec.temporary_exempt_end_date + and date >= rec.temporary_exempt_start_date + and date <= rec.temporary_exempt_end_date + ): + date = add_days_delta(date, 1) continue - else: - counter -= 1 + # Otherwise + counter -= 1 date = add_days_delta(date, 1) rec.future_alert_date = self._next_countdown_date( rec.irregular_start_date, date @@ -195,20 +201,24 @@ class CooperativeStatus(models.Model): while not next_countdown_date: date = self._next_countdown_date(rec.irregular_start_date, date) # Check holidays - if (rec.holiday_start_time and rec.holiday_end_time - and date >= rec.holiday_start_time - and date <= rec.holiday_end_time): + if ( + rec.holiday_start_time and rec.holiday_end_time + and date >= rec.holiday_start_time + and date <= rec.holiday_end_time + ): date = add_days_delta(date, 1) continue # Check temporary exemption - elif (rec.temporary_exempt_start_date - and rec.temporary_exempt_end_date - and date >= rec.temporary_exempt_start_date - and date <= rec.temporary_exempt_end_date): + if ( + rec.temporary_exempt_start_date + and rec.temporary_exempt_end_date + and date >= rec.temporary_exempt_start_date + and date <= rec.temporary_exempt_end_date + ): date = add_days_delta(date, 1) continue - else: - next_countdown_date = date + # Otherwise + next_countdown_date = date rec.next_countdown_date = next_countdown_date @api.constrains("working_mode", "irregular_start_date")