From 9fde3dc0bec3f655a4d625f81ee6bc21ccac448f Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Sun, 8 Jan 2017 00:44:12 +0100 Subject: [PATCH] =?UTF-8?q?[ADD]=20Improve=20Shift=20management=20apr?= =?UTF-8?q?=C3=A8s=20avoir=20g=C3=A9n=C3=A9r=C3=A9=20les=20shifts=20pour?= =?UTF-8?q?=20une=20semaine,=20rediriger=20vers=20les=20shifts=20g=C3=A9n?= =?UTF-8?q?=C3=A9r=C3=A9s=20:=20ok=20Ajouter=20un=20supercoop=C3=A9rateur?= =?UTF-8?q?=20au=20niveau=20du=20template=20de=20shift.=20Pas=20de=20champ?= =?UTF-8?q?s=20related=20car=20il=20faut=20pouvoir=20g=C3=A9rer=20les=20re?= =?UTF-8?q?mplacements=20entre=20supercoop=C3=A9rateurs.=20:=20Rajouter=20?= =?UTF-8?q?un=20boolean=20sur=20res.users=20pour=20dire=20qu'ils=20sont=20?= =?UTF-8?q?super=20coop=C3=A9rateur=20du=20coup=20on=20peut=20choisir=20qu?= =?UTF-8?q?'un=20utilisateur=20super=20coop=C3=A9rateur=20:=20Ok=20Sur=20l?= =?UTF-8?q?a=20vue=20des=20shifts,=20permettre=20de=20s=C3=A9lectionner=20?= =?UTF-8?q?un=20ensemble=20de=20shifts=20pour=20pouvoir=20changer=20son=20?= =?UTF-8?q?supercoop=C3=A9rateur=20en=20une=20action=20:=20Ok=20Avoir=20un?= =?UTF-8?q?e=20vue=20des=20shifts=20par=20d=C3=A9faut=20plus=20lisible=20q?= =?UTF-8?q?ue=20le=20calendrier=20:=20KANBAN=20avec=20TODAY=20par=20d?= =?UTF-8?q?=C3=A9faut=20et=20les=20colonnes=20selon=20le=20type=20de=20shi?= =?UTF-8?q?ft=20:=20ok=20Dans=20la=20vue=20KANBAN=20du=20planning=20des=20?= =?UTF-8?q?semaines,=20faire=20un=20tri=20sur=20la=20start=20date=20pour?= =?UTF-8?q?=20que=20=C3=A7a=20ressemble=20=C3=A0=20une=20vue=20calendrier?= =?UTF-8?q?=20:ok=20Droits=20d'acc=C3=A8s=20:=203=20groupes=20:=20modifier?= =?UTF-8?q?=20un=20shift=20existant=20et=20confirmer=20son=20statut=20:=20?= =?UTF-8?q?absence/pr=C3=A9sence=20g=C3=A9n=C3=A9rer=20et=20supprimer=20de?= =?UTF-8?q?s=20shifts=20=C3=A0=20partir=20du=20template=20modifier=20le=20?= =?UTF-8?q?template=20des=20semaines=20et=20g=C3=A9rer=20la=20config=20En?= =?UTF-8?q?=20r=C3=A9fl=C3=A9chissant=20=C3=A0=20ceux=20qui=20vont=20g?= =?UTF-8?q?=C3=A9rer=20les=20pr=C3=A9sences=20:=20il=20faudrait=20avoir=20?= =?UTF-8?q?une=20vue=20facile=20sur=20les=20shifts=20du=20jour=20et=20une?= =?UTF-8?q?=20mani=C3=A8re=20simple=20de=20dire=20pr=C3=A9sent/absent/remp?= =?UTF-8?q?lac=C3=A9=20pour=20l'ensemble=20des=20coop=C3=A9rateurs=20pr?= =?UTF-8?q?=C3=A9sents=20(=C3=A9viter=20de=20devoir=20chaque=20fois=20s?= =?UTF-8?q?=C3=A9lectionner=20le=20shift,=20cliquer=20sur=20le=20statut,?= =?UTF-8?q?=20aller=20au=20shift=20suivant,=20cliquer=20sur=20le=20statut.?= =?UTF-8?q?..).=20J'ai=20fait=20un=20nouveau=20point=20de=20menu=20avec=20?= =?UTF-8?q?une=20vue=20Kanban=20grouper=20par=20status,=20il=20suffit=20de?= =?UTF-8?q?=20faire=20du=20drag=20and=20drop=20pour=20changer=20le=20statu?= =?UTF-8?q?s,=20les=20shifts=20sont=20aussi=20filtr=C3=A9=20sur=20aujourd'?= =?UTF-8?q?hui=20et=20seulement=20ceux=20ayant=20un=20worker=20assign?= =?UTF-8?q?=C3=A9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- beesdoo_shift/__openerp__.py | 6 +- beesdoo_shift/data/stage.xml | 37 +++++ beesdoo_shift/models/__init__.py | 3 +- beesdoo_shift/models/planning.py | 15 +- beesdoo_shift/models/res_users.py | 7 + beesdoo_shift/models/task.py | 40 ++++-- beesdoo_shift/security/group.xml | 18 +++ beesdoo_shift/security/ir.model.access.csv | 18 ++- beesdoo_shift/views/planning.xml | 8 +- beesdoo_shift/views/res_users.xml | 13 ++ beesdoo_shift/views/task.xml | 134 +++++++++++++++++- beesdoo_shift/views/task_template.xml | 71 ++++++---- beesdoo_shift/wizard/__init__.py | 3 +- beesdoo_shift/wizard/assign_super_coop.py | 14 ++ beesdoo_shift/wizard/assign_super_coop.xml | 27 ++++ beesdoo_shift/wizard/batch_template.py | 2 +- beesdoo_shift/wizard/batch_template.xml | 15 +- beesdoo_shift/wizard/instanciate_planning.py | 14 +- beesdoo_shift/wizard/instanciate_planning.xml | 6 +- 19 files changed, 378 insertions(+), 73 deletions(-) create mode 100644 beesdoo_shift/data/stage.xml create mode 100644 beesdoo_shift/models/res_users.py create mode 100644 beesdoo_shift/security/group.xml create mode 100644 beesdoo_shift/views/res_users.xml create mode 100644 beesdoo_shift/wizard/assign_super_coop.py create mode 100644 beesdoo_shift/wizard/assign_super_coop.xml diff --git a/beesdoo_shift/__openerp__.py b/beesdoo_shift/__openerp__.py index 4a2a996..9ec7d50 100644 --- a/beesdoo_shift/__openerp__.py +++ b/beesdoo_shift/__openerp__.py @@ -12,17 +12,21 @@ 'author': "Thibault Francois", 'website': "https://github.com/beescoop/Obeesdoo", - 'category': 'Coop', + 'category': 'Cooperative management', 'version': '0.1', 'depends': ['beesdoo_base'], 'data': [ + "data/stage.xml", + "security/group.xml", "security/ir.model.access.csv", "views/task_template.xml", "views/task.xml", "views/planning.xml", + "views/res_users.xml", "wizard/instanciate_planning.xml", "wizard/batch_template.xml", + "wizard/assign_super_coop.xml", ], } diff --git a/beesdoo_shift/data/stage.xml b/beesdoo_shift/data/stage.xml new file mode 100644 index 0000000..2fd2f54 --- /dev/null +++ b/beesdoo_shift/data/stage.xml @@ -0,0 +1,37 @@ + + + Unconfirmed + 1 + 0 + + + Confirmed + 2 + 5 + + + Attended + 3 + 1 + + + Replaced + 4 + 5 + + + Absent + 5 + 2 + + + Excused + 6 + 4 + + + Cancelled + 7 + 8 + + diff --git a/beesdoo_shift/models/__init__.py b/beesdoo_shift/models/__init__.py index 14cfb0e..b011d24 100644 --- a/beesdoo_shift/models/__init__.py +++ b/beesdoo_shift/models/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- import planning -import task \ No newline at end of file +import task +import res_users \ No newline at end of file diff --git a/beesdoo_shift/models/planning.py b/beesdoo_shift/models/planning.py index 421c6bc..88dedc3 100644 --- a/beesdoo_shift/models/planning.py +++ b/beesdoo_shift/models/planning.py @@ -28,7 +28,7 @@ class TaskType(models.Model): class DayNumber(models.Model): _name = 'beesdoo.shift.daynumber' - + _order = 'number asc' name = fields.Char() @@ -44,12 +44,15 @@ class Planning(models.Model): class TaskTemplate(models.Model): _name = 'beesdoo.shift.template' + _order = 'start_time' + name = fields.Char(required=True) planning_id = fields.Many2one('beesdoo.shift.planning', required=True) day_nb_id = fields.Many2one('beesdoo.shift.daynumber', string='Day', required=True) task_type_id = fields.Many2one('beesdoo.shift.type', string="Type") start_time = fields.Float(required=True) end_time = fields.Float(required=True) + super_coop_id = fields.Many2one('res.users', string="Super Cooperative", domain=[('super', '=', True)]) duration = fields.Float(help="Duration in Hour") worker_nb = fields.Integer(string="Number of worker", help="Max number of worker for this task", default=1) @@ -72,7 +75,7 @@ class TaskTemplate(models.Model): h_end, m_end = floatime_to_hour_minute(rec.end_time) rec.start_date = fields.Datetime.context_timestamp(self, day).replace(hour=h_begin, minute=m_begin, second=0).astimezone(UTC) rec.end_date = fields.Datetime.context_timestamp(self, day).replace(hour=h_end, minute=m_end, second=0).astimezone(UTC) - + def _dummy_search(self, operator, value): return [] @@ -85,7 +88,7 @@ class TaskTemplate(models.Model): def _get_worker_name(self): for rec in self: rec.worker_name = ','.join(rec.worker_ids.mapped('display_name')) - + @api.constrains('worker_nb', 'worker_ids') def _nb_worker_max(self): for rec in self: @@ -97,7 +100,7 @@ class TaskTemplate(models.Model): def _get_duration(self): if self.start_time and self.end_time: self.duration = self.end_time - self.start_time - + @api.onchange('duration') def _set_duration(self): if self.start_time: @@ -108,11 +111,13 @@ class TaskTemplate(models.Model): for rec in self: for i in xrange(0, rec.worker_nb): tasks |= tasks.create({ - 'name' : "%s (%s) - (%s) [%s]" % (rec.name, float_to_time(rec.start_time), float_to_time(rec.end_time), i), + 'name' : "%s %s (%s - %s) [%s]" % (rec.name, rec.day_nb_id.name, float_to_time(rec.start_time), float_to_time(rec.end_time), i), 'task_template_id' : rec.id, 'task_type_id' : rec.task_type_id.id, + 'super_coop_id': rec.super_coop_id.id, 'worker_id' : rec.worker_ids[i].id if len(rec.worker_ids) > i else False, 'start_time' : rec.start_date, 'end_time' : rec.end_date, + 'stage_id': self.env.ref('beesdoo_shift.draft').id, }) return tasks \ No newline at end of file diff --git a/beesdoo_shift/models/res_users.py b/beesdoo_shift/models/res_users.py new file mode 100644 index 0000000..82452d0 --- /dev/null +++ b/beesdoo_shift/models/res_users.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +from openerp import models, fields + +class ResUsers(models.Model): + _inherit = 'res.users' + + super = fields.Boolean("Super Cooperative") \ No newline at end of file diff --git a/beesdoo_shift/models/task.py b/beesdoo_shift/models/task.py index d603b7e..a858395 100644 --- a/beesdoo_shift/models/task.py +++ b/beesdoo_shift/models/task.py @@ -1,22 +1,22 @@ # -*- coding: utf-8 -*- -from openerp import models, fields - -STATES = [ - ('draft', 'Unconfirmed'), - ('open', 'Confirmed'), - ('done', 'Attended'), - ('absent', 'Absent'), - ('excused', 'Excused'), - ('replaced', 'Replaced'), - ('cancel', 'Cancelled'), -] +from openerp import models, fields, api + +class TaskStage(models.Model): + _name = 'beesdoo.shift.stage' + _order = 'sequence asc' + + name = fields.Char() + sequence = fields.Integer() + color = fields.Integer() + class Task(models.Model): _name = 'beesdoo.shift.shift' - #EX01 ADD inheritance _inherit = ['mail.thread'] + _order = "start_time asc" + name = fields.Char(track_visibility='always') task_template_id = fields.Many2one('beesdoo.shift.template') planning_id = fields.Many2one(related='task_template_id.planning_id', store=True) @@ -24,7 +24,9 @@ class Task(models.Model): worker_id = fields.Many2one('res.partner', track_visibility='onchange', domain=[('eater', '=', 'worker_eater')]) start_time = fields.Datetime(track_visibility='always') end_time = fields.Datetime(track_visibility='always') - state = fields.Selection(STATES, default='draft', track_visibility='onchange') + stage_id = fields.Many2one('beesdoo.shift.stage', required=True, track_visibility='onchange') + super_coop_id = fields.Many2one('res.users', string="Super Cooperative", domain=[('super', '=', True)], track_visibility='onchange') + color = fields.Integer(related="stage_id.color", readonly=True) def message_auto_subscribe(self, updated_fields, values=None): self._add_follower(values) @@ -33,4 +35,14 @@ class Task(models.Model): def _add_follower(self, vals): if vals.get('worker_id'): worker = self.env['res.partner'].browse(vals['worker_id']) - self.message_subscribe(partner_ids=worker.ids) \ No newline at end of file + self.message_subscribe(partner_ids=worker.ids) + + @api.model + def _read_group_stage_id(self, ids, domain, read_group_order=None, access_rights_uid=None): + res = self.env['beesdoo.shift.stage'].search([]).name_get() + fold = dict.fromkeys([r[0] for r in res], False) + return res, fold + + _group_by_full = { + 'stage_id': _read_group_stage_id, + } \ No newline at end of file diff --git a/beesdoo_shift/security/group.xml b/beesdoo_shift/security/group.xml new file mode 100644 index 0000000..36cfaa8 --- /dev/null +++ b/beesdoo_shift/security/group.xml @@ -0,0 +1,18 @@ + + + + Shift Attendance + + + + Shift Management + + + + + Planning Management + + + + + \ No newline at end of file diff --git a/beesdoo_shift/security/ir.model.access.csv b/beesdoo_shift/security/ir.model.access.csv index a63e74b..d415430 100644 --- a/beesdoo_shift/security/ir.model.access.csv +++ b/beesdoo_shift/security/ir.model.access.csv @@ -1,6 +1,14 @@ id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink -access_coopplanning_task_type,access_coopplanning_task_type,model_beesdoo_shift_type,,1,1,1,1 -access_coopplanning_daynumber,access_coopplanning_daynumber,model_beesdoo_shift_daynumber,,1,1,1,1 -access_coopplanning_planning,access_coopplanning_planning,model_beesdoo_shift_planning,,1,1,1,1 -access_coopplanning_task_template,access_coopplanning_task_template,model_beesdoo_shift_template,,1,1,1,1 -access_coopplanning_task,access_coopplanning_task,model_beesdoo_shift_shift,,1,1,1,1 +access_coopplanning_task_stage,Attendance Read Stage,model_beesdoo_shift_stage,group_shift_attendance,1,0,0,0 +access_coopplanning_task_type,Attendance Read Type,model_beesdoo_shift_type,group_shift_attendance,1,0,0,0 +access_coopplanning_daynumber,Attendance Read Daynumber,model_beesdoo_shift_daynumber,group_shift_attendance,1,0,0,0 +access_coopplanning_planning,Attendance Read Planning,model_beesdoo_shift_planning,group_shift_attendance,1,0,0,0 +access_coopplanning_task_template,Attendance Read Template,model_beesdoo_shift_template,group_shift_attendance,1,0,0,0 +access_coopplanning_task,Attendance Edit Shift,model_beesdoo_shift_shift,group_shift_attendance,1,1,0,0 +access_coopplanning_task_full,Shift Management all Shift,model_beesdoo_shift_shift,group_shift_management,1,1,1,1 +all_config_coopplanning_task_stage,Attendance Read Stage,model_beesdoo_shift_stage,group_planning_management,1,1,1,1 +all_config_coopplanning_task_type,Attendance Read Type,model_beesdoo_shift_type,group_planning_management,1,1,1,1 +all_config_coopplanning_daynumber,Attendance Read Daynumber,model_beesdoo_shift_daynumber,group_planning_management,1,1,1,1 +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 diff --git a/beesdoo_shift/views/planning.xml b/beesdoo_shift/views/planning.xml index 4aace85..8b42baa 100644 --- a/beesdoo_shift/views/planning.xml +++ b/beesdoo_shift/views/planning.xml @@ -15,7 +15,8 @@ kanban,tree,form,calendar,pivot {'group_by': 'day_nb_id', 'search_default_planning_id': active_id, - 'default_planning_id': active_id} + 'default_planning_id': active_id} + @@ -31,7 +32,7 @@
- +
@@ -49,7 +50,8 @@