From 79a4ab3e6785d15f12fd124ee7114afd5201c660 Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Mon, 7 Aug 2017 23:36:14 +0200 Subject: [PATCH] [IMP] default value to true when unsubscribed to reset counter + possibility to reset compensation counter --- beesdoo_shift/wizard/subscribe.py | 8 +++++++- beesdoo_shift/wizard/subscribe.xml | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/beesdoo_shift/wizard/subscribe.py b/beesdoo_shift/wizard/subscribe.py index 24a25ee..c910599 100644 --- a/beesdoo_shift/wizard/subscribe.py +++ b/beesdoo_shift/wizard/subscribe.py @@ -32,6 +32,9 @@ class Subscribe(models.TransientModel): def _get_mode(self): return self.env['res.partner'].browse(self._context.get('active_id')).working_mode + def _get_reset_counter_default(self): + return self.env['res.partner'].browse(self._context.get('active_id')).state == 'unsubscribed' + info_session = fields.Boolean(string="Followed an information session", default=True) info_session_date = fields.Date(string="Date of information session", default=_get_date) super = fields.Boolean(string="Super Cooperator", default=_get_super) @@ -44,7 +47,8 @@ class Subscribe(models.TransientModel): ) exempt_reason_id = fields.Many2one('cooperative.exempt.reason', 'Exempt Reason') shift_id = fields.Many2one('beesdoo.shift.template') - reset_counter = fields.Boolean(default=False) + reset_counter = fields.Boolean(default=_get_reset_counter_default) + reset_compensation_counter = fields.Boolean(default=False) unsubscribed = fields.Boolean(default=False, string="Are you sure to unsubscribe this cooperator") @@ -91,6 +95,8 @@ class Subscribe(models.TransientModel): data['extension_start_time'] = False data['alert_start_time'] = False data['time_extension'] = 0 + if self.reset_compensation_counter: + data['sc'] = 0 status_id = self.env['cooperative.status'].search([('cooperator_id', '=', self.cooperator_id.id)]) if status_id: diff --git a/beesdoo_shift/wizard/subscribe.xml b/beesdoo_shift/wizard/subscribe.xml index 877e818..830816a 100644 --- a/beesdoo_shift/wizard/subscribe.xml +++ b/beesdoo_shift/wizard/subscribe.xml @@ -14,9 +14,10 @@ - + +