diff --git a/beesdoo_shift/data/system_parameter.xml b/beesdoo_shift/data/system_parameter.xml
index cc5a4ec..6d8b96e 100644
--- a/beesdoo_shift/data/system_parameter.xml
+++ b/beesdoo_shift/data/system_parameter.xml
@@ -23,4 +23,8 @@
next_planning_date
1970-01-01
+
+ irregular_counter_to_unsubscribe
+ -4
+
\ No newline at end of file
diff --git a/beesdoo_shift/models/cooperative_status.py b/beesdoo_shift/models/cooperative_status.py
index 76e2a3d..c73ed96 100644
--- a/beesdoo_shift/models/cooperative_status.py
+++ b/beesdoo_shift/models/cooperative_status.py
@@ -160,11 +160,11 @@ class CooperativeStatus(models.Model):
self.can_shop = True
def _set_irregular_status(self, grace_delay, alert_delay):
+ counter_unsubscribe = int(self.env['ir.config_parameter'].get_param('irregular_counter_to_unsubscribe', -3))
self.ensure_one()
ok = self.sr >= 0
grace_delay = grace_delay + self.time_extension
- if (not ok and self.irregular_absence_date and self.today > add_days_delta(self.irregular_absence_date, alert_delay * 2)) \
- or self.unsubscribed or self.irregular_absence_counter <= -2:
+ if self.sr <= counter_unsubscribe or self.unsubscribed:
self.status = 'unsubscribed'
self.can_shop = False
elif self.today >= self.temporary_exempt_start_date and self.today <= self.temporary_exempt_end_date:
diff --git a/beesdoo_shift/models/task.py b/beesdoo_shift/models/task.py
index 8043670..51d99c6 100644
--- a/beesdoo_shift/models/task.py
+++ b/beesdoo_shift/models/task.py
@@ -28,7 +28,12 @@ class Task(models.Model):
task_template_id = fields.Many2one('beesdoo.shift.template')
planning_id = fields.Many2one(related='task_template_id.planning_id', store=True)
task_type_id = fields.Many2one('beesdoo.shift.type', string="Task Type")
- worker_id = fields.Many2one('res.partner', track_visibility='onchange', domain=[('eater', '=', 'worker_eater'), ('working_mode', 'in', ('regular', 'irregular'))])
+ worker_id = fields.Many2one('res.partner', track_visibility='onchange',
+ domain=[
+ ('eater', '=', 'worker_eater'),
+ ('working_mode', 'in', ('regular', 'irregular')),
+ ('state', 'not in', ('unsubscribed', 'resigning')),
+ ])
start_time = fields.Datetime(track_visibility='always', index=True)
end_time = fields.Datetime(track_visibility='always')
stage_id = fields.Many2one('beesdoo.shift.stage', required=True, track_visibility='onchange', default=lambda self: self.env.ref('beesdoo_shift.open'))