Browse Source

[CHANGE] Change the computation for unsubscribed status of irregular worker

They become unsubscribe when the regular counter fall under a value that can be define in parameter
[FIX] don't show unsubscribed or resigning worker in the list of worker you can assign on a shift
pull/56/head
Thibault Francois 6 years ago
parent
commit
242fcd7c29
  1. 4
      beesdoo_shift/data/system_parameter.xml
  2. 4
      beesdoo_shift/models/cooperative_status.py
  3. 7
      beesdoo_shift/models/task.py

4
beesdoo_shift/data/system_parameter.xml

@ -23,4 +23,8 @@
<field name="key">next_planning_date</field>
<field name="value">1970-01-01</field>
</record>
<record id="irregular_unsubscribe" model="ir.config_parameter">
<field name="key">irregular_counter_to_unsubscribe</field>
<field name="value">-4</field>
</record>
</odoo>

4
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:

7
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'))

Loading…
Cancel
Save