From 211e24a5c57347321ebd02f419cf7e9d49d231e0 Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Fri, 21 Jul 2017 14:11:36 +0200 Subject: [PATCH] [WIP] --- beesdoo_shift/__openerp__.py | 1 + beesdoo_shift/models/cooperative_status.py | 26 +++++++++++++++++++++- beesdoo_shift/security/ir.model.access.csv | 3 ++- beesdoo_shift/views/cooperative_status.xml | 2 ++ beesdoo_shift/views/exempt_reason.xml | 21 +++++++++++++++++ beesdoo_shift/wizard/subscribe.py | 2 ++ beesdoo_shift/wizard/subscribe.xml | 1 + 7 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 beesdoo_shift/views/exempt_reason.xml diff --git a/beesdoo_shift/__openerp__.py b/beesdoo_shift/__openerp__.py index a87a609..7ad419a 100644 --- a/beesdoo_shift/__openerp__.py +++ b/beesdoo_shift/__openerp__.py @@ -26,6 +26,7 @@ "views/task.xml", "views/planning.xml", "views/cooperative_status.xml", + "views/exempt_reason.xml", "wizard/instanciate_planning.xml", "wizard/batch_template.xml", "wizard/assign_super_coop.xml", diff --git a/beesdoo_shift/models/cooperative_status.py b/beesdoo_shift/models/cooperative_status.py index 69ebd85..efb07f0 100644 --- a/beesdoo_shift/models/cooperative_status.py +++ b/beesdoo_shift/models/cooperative_status.py @@ -2,6 +2,11 @@ from openerp import models, fields, api, _ from openerp.exceptions import ValidationError +class ExemptReason(models.Model): + _name = 'cooperative.exempt.reason' + + name = fields.Char(required=True) + class CooperativeStatus(models.Model): _name = 'cooperative.status' _rec_name = 'cooperator_id' @@ -25,8 +30,26 @@ class CooperativeStatus(models.Model): ('irregular', 'Irregular worker'), ('exempt', 'Exempted'), ], - string="Working mode", + string="Working mode" ) + exempt_reason_id = fields.Many2one('cooperative.exempt.reason', 'Exempt Reason') +# cooperator_type = fields.Selection(related="cooperator_id.cooperator_type", store=True) +# +# def _auto_working_mode(self, vals): +# print "Auto Working mode" +# if vals.get('cooperator_type') == 'share_b': +# vals['working_mode'] = 'exempt' +# +# @api.model +# @api.returns('self', lambda value:value.id) +# def create(self, vals): +# self._auto_working_mode(vals) +# return super(CooperativeStatus, self).create(self, vals) +# +# @api.multi +# def _write(self, vals): +# self._auto_working_mode(vals) +# return super(CooperativeStatus, self)._write(vals) def _compute_status(self): for rec in self: @@ -44,6 +67,7 @@ class ResPartner(models.Model): info_session = fields.Boolean(related='cooperative_status_ids.info_session', string='Information Session ?', readonly=True, store=True) info_session_date = fields.Datetime(related='cooperative_status_ids.info_session_date', string='Information Session Date', readonly=True, store=True) working_mode = fields.Selection(related='cooperative_status_ids.working_mode', readonly=True, store=True) + exempt_reason_id = fields.Many2one(related='cooperative_status_ids.exempt_reason_id', readonly=True, store=True) subscribed_shift_ids = fields.Many2many('beesdoo.shift.template') @api.multi def coop_subscribe(self): diff --git a/beesdoo_shift/security/ir.model.access.csv b/beesdoo_shift/security/ir.model.access.csv index f90d443..9376d04 100644 --- a/beesdoo_shift/security/ir.model.access.csv +++ b/beesdoo_shift/security/ir.model.access.csv @@ -14,4 +14,5 @@ all_config_coopplanning_daynumber,Attendance Read Daynumber,model_beesdoo_shift_ all_config_coopplanning_planning,Attendance Read Planning,model_beesdoo_shift_planning,group_planning_management,1,1,1,1 all_config_coopplanning_task_template,Attendance Read Template,model_beesdoo_shift_template,group_planning_management,1,1,1,1 all_config_coopplanning_task,Attendance Edit Shift,model_beesdoo_shift_shift,group_planning_management,1,1,1,1 - +exempt_reason_read_all,Exempt Reason Read all ,beesdoo_shift.model_cooperative_exempt_reason,,1,0,0,0 +exempt_reason,Exempt Reason Admin,beesdoo_shift.model_cooperative_exempt_reason,beesdoo_shift.group_cooperative_admin,1,1,1,1 diff --git a/beesdoo_shift/views/cooperative_status.xml b/beesdoo_shift/views/cooperative_status.xml index b3e16d5..246a40d 100644 --- a/beesdoo_shift/views/cooperative_status.xml +++ b/beesdoo_shift/views/cooperative_status.xml @@ -20,6 +20,7 @@ + @@ -42,6 +43,7 @@ + diff --git a/beesdoo_shift/views/exempt_reason.xml b/beesdoo_shift/views/exempt_reason.xml new file mode 100644 index 0000000..85c54d6 --- /dev/null +++ b/beesdoo_shift/views/exempt_reason.xml @@ -0,0 +1,21 @@ + + + Exempt Reason Tree view + cooperative.exempt.reason + + + + + + + + Exempt Reason + cooperative.exempt.reason + tree + + + + + + diff --git a/beesdoo_shift/wizard/subscribe.py b/beesdoo_shift/wizard/subscribe.py index d7ef409..5be9c00 100644 --- a/beesdoo_shift/wizard/subscribe.py +++ b/beesdoo_shift/wizard/subscribe.py @@ -26,6 +26,7 @@ class Subscribe(models.TransientModel): ('exempt', 'Exempted'), ], ) + exempt_reason_id = fields.Many2one('cooperative.exempt.reason', 'Exempt Reason') shift_id = fields.Many2one('beesdoo.shift.template') @api.multi @@ -43,6 +44,7 @@ class Subscribe(models.TransientModel): 'info_session' : self.info_session, 'info_session_date': self.info_session_date, 'working_mode' : self.working_mode, + 'exempt_reason_id' : self.exempt_reason_id.id, 'super' : self.super, 'cooperator_id': self.cooperator_id.id, 'sr' : 0, #set back to 0 if you subscribe a second time diff --git a/beesdoo_shift/wizard/subscribe.xml b/beesdoo_shift/wizard/subscribe.xml index 1bacc38..2bf0316 100644 --- a/beesdoo_shift/wizard/subscribe.xml +++ b/beesdoo_shift/wizard/subscribe.xml @@ -9,6 +9,7 @@ +