|
|
@ -7,6 +7,7 @@ import logging |
|
|
|
from openerp.osv.fields import related |
|
|
|
|
|
|
|
_logger = logging.getLogger(__name__) |
|
|
|
PERIOD = 28 # TODO: use system parameter |
|
|
|
|
|
|
|
def add_days_delta(date_from, days_delta): |
|
|
|
if not date_from: |
|
|
@ -76,6 +77,7 @@ class CooperativeStatus(models.Model): |
|
|
|
irregular_start_date = fields.Date() #TODO migration script |
|
|
|
irregular_absence_date = fields.Date() |
|
|
|
irregular_absence_counter = fields.Integer() #TODO unsubscribe when reach -2 |
|
|
|
future_alert_date = fields.Date(compute='_compute_future_alert_date') |
|
|
|
|
|
|
|
temporary_exempt_reason_id = fields.Many2one('cooperative.exempt.reason', 'Exempt Reason') |
|
|
|
temporary_exempt_start_date = fields.Date() |
|
|
@ -110,6 +112,18 @@ class CooperativeStatus(models.Model): |
|
|
|
rec.status = 'ok' |
|
|
|
rec.can_shop = True |
|
|
|
|
|
|
|
@api.depends('today', 'irregular_start_date', 'sr') |
|
|
|
def _compute_future_alert_date(self): |
|
|
|
"""Compute date before which the worker is up to date""" |
|
|
|
for rec in self: |
|
|
|
future_alert_date = False |
|
|
|
if not rec.alert_start_time and rec.irregular_start_date: |
|
|
|
today_date = fields.Date.from_string(rec.today) |
|
|
|
delta = (today_date - fields.Date.from_string(rec.irregular_start_date)).days |
|
|
|
future_alert_date = today_date + timedelta(days=(rec.sr + 1) * PERIOD - delta % PERIOD) |
|
|
|
future_alert_date = future_alert_date.strftime('%Y-%m-%d') |
|
|
|
rec.future_alert_date = future_alert_date |
|
|
|
|
|
|
|
def _set_regular_status(self, grace_delay, alert_delay): |
|
|
|
self.ensure_one() |
|
|
|
ok = self.sr >= 0 and self.sc >= 0 |
|
|
@ -266,7 +280,7 @@ class CooperativeStatus(models.Model): |
|
|
|
if status.status == 'exempted': |
|
|
|
continue |
|
|
|
delta = (today_date - fields.Date.from_string(status.irregular_start_date)).days |
|
|
|
if delta and delta % 28 == 0 and status not in journal.line_ids: #TODO use system parameter for 28 |
|
|
|
if delta and delta % PERIOD == 0 and status not in journal.line_ids: |
|
|
|
if status.sr > 0: |
|
|
|
status.sr -= 1 |
|
|
|
else: |
|
|
|