Browse Source

[FIX] b_shift: Unsubscribe resigning worker

pull/80/head
Rémy Taymans 6 years ago
parent
commit
2dc776735e
  1. 2
      beesdoo_shift/__openerp__.py
  2. 7
      beesdoo_shift/models/cooperative_status.py

2
beesdoo_shift/__openerp__.py

@ -13,7 +13,7 @@
'website': "https://github.com/beescoop/Obeesdoo",
'category': 'Cooperative management',
'version': '0.1',
'version': '9.0.1.0.1',
'depends': ['beesdoo_base'],

7
beesdoo_shift/models/cooperative_status.py

@ -222,8 +222,15 @@ class CooperativeStatus(models.Model):
data['alert_start_time'] = False
self.write(data)
if new_state == 'unsubscribed' or new_state == 'resigning':
# Remove worker from task_templates
self.cooperator_id.sudo().write(
{'subscribed_shift_ids': [(5, 0, 0)]})
# Remove worker from supercoop in task_templates
task_tpls = self.env['beesdoo.shift.template'].search(
[('super_coop_id', 'in', self.cooperator_id.user_ids.ids)]
)
task_tpls.write({'super_coop_id': False})
# Remove worker for future task (remove also supercoop)
# TODO: Add one day otherwise unsubscribed from the shift you were absent
self.env['beesdoo.shift.shift'].sudo().unsubscribe_from_today(
[self.cooperator_id.id], today=fields.Date.today())

Loading…
Cancel
Save