From d7a70778d467ae17a38847106ea193fcd474a98b Mon Sep 17 00:00:00 2001 From: nicolasjamoulle Date: Tue, 19 Mar 2019 11:33:18 +0100 Subject: [PATCH] [ADD] Remove super cooperative from future planning --- beesdoo_shift/models/task.py | 17 +++++++++++------ beesdoo_shift/wizard/subscribe.py | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/beesdoo_shift/models/task.py b/beesdoo_shift/models/task.py index a97811b..a915a77 100644 --- a/beesdoo_shift/models/task.py +++ b/beesdoo_shift/models/task.py @@ -81,12 +81,17 @@ class Task(models.Model): to_unsubscribe_replace = self.search([('replaced_id', 'in', worker_ids)] + date_domain) to_unsubscribe_replace.write({'worker_id': False, 'is_regular': False, 'replaced_id': False}) - # if self.super_coop_id.id: - # to_unsubscribe_super_coop = self.search([('super_coop_id', 'in', - # self.super_coop_id.id)] - # + date_domain) - # to_unsubscribe_super_coop.write({'super_coop_id': False, - # 'is_regular': False}) + # If worker is Super cooperative, remove it + super_coop_id = self.env['res.users'].search( + [('partner_id', '=', worker_ids[0]), ('super', '=', True)]).id + + if super_coop_id: + to_unsubscribe_super_coop = self.search([('super_coop_id', '=', + super_coop_id), + ('start_time', '>=', + today)]) + to_unsubscribe_super_coop.write({'super_coop_id': False, + 'is_regular': False}) @api.multi def write(self, vals): diff --git a/beesdoo_shift/wizard/subscribe.py b/beesdoo_shift/wizard/subscribe.py index b72a13a..9d2be66 100644 --- a/beesdoo_shift/wizard/subscribe.py +++ b/beesdoo_shift/wizard/subscribe.py @@ -81,7 +81,7 @@ class Subscribe(models.TransientModel): data = { 'unsubscribed': True, 'cooperator_id': self.cooperator_id.id, - 'resigning' : self.resigning, + 'resigning': self.resigning, } if status_id: status_id.sudo().write(data)