Browse Source

[S0047] Faire le suivi des inscriptions aux séances info/inscriptions shifts

pull/15/head
Thibault Francois 8 years ago
parent
commit
db2f8986cd
  1. 2
      beesdoo_base/models/partner.py
  2. 6
      beesdoo_base/views/partner.xml
  3. 4
      beesdoo_shift/__openerp__.py
  4. 10
      beesdoo_shift/data/stage.xml
  5. 10
      beesdoo_shift/data/system_parameter.xml
  6. 2
      beesdoo_shift/models/__init__.py
  7. 59
      beesdoo_shift/models/cooperative_status.py
  8. 4
      beesdoo_shift/models/planning.py
  9. 25
      beesdoo_shift/models/res_users.py
  10. 6
      beesdoo_shift/models/task.py
  11. 5
      beesdoo_shift/security/group.xml
  12. 3
      beesdoo_shift/security/ir.model.access.csv
  13. 82
      beesdoo_shift/views/cooperative_status.xml
  14. 29
      beesdoo_shift/views/res_users.xml
  15. 6
      beesdoo_shift/views/task.xml
  16. 3
      beesdoo_shift/wizard/__init__.py
  17. 55
      beesdoo_shift/wizard/subscribe.py
  18. 24
      beesdoo_shift/wizard/subscribe.xml

2
beesdoo_base/models/partner.py

@ -21,8 +21,6 @@ class Partner(models.Model):
member_card_to_be_printed = fields.Boolean('Print BEES card?') member_card_to_be_printed = fields.Boolean('Print BEES card?')
last_printed = fields.Datetime('Last printed on') last_printed = fields.Datetime('Last printed on')
info_session = fields.Boolean('Information Session ?')
info_session_date = fields.Datetime('Information Session Date')
@api.onchange('first_name', 'last_name') @api.onchange('first_name', 'last_name')
def _on_change_name(self): def _on_change_name(self):

6
beesdoo_base/views/partner.xml

@ -34,11 +34,7 @@
<page string="Member Card" <page string="Member Card"
attrs="{'invisible': ['|', ('customer', '=', False), ('eater', '!=', 'worker_eater')]}"> attrs="{'invisible': ['|', ('customer', '=', False), ('eater', '!=', 'worker_eater')]}">
<group> <group>
<group>
<field name="info_session" />
<field name="info_session_date"
attrs="{'invisible': ['|', ('info_session', '=', False)]}" />
</group>
<group name="info_session" />
<group> <group>
<field name="member_card_to_be_printed" /> <field name="member_card_to_be_printed" />
<field name="last_printed" /> <field name="last_printed" />

4
beesdoo_shift/__openerp__.py

@ -19,14 +19,16 @@
'data': [ 'data': [
"data/stage.xml", "data/stage.xml",
"data/system_parameter.xml",
"security/group.xml", "security/group.xml",
"security/ir.model.access.csv", "security/ir.model.access.csv",
"views/task_template.xml", "views/task_template.xml",
"views/task.xml", "views/task.xml",
"views/planning.xml", "views/planning.xml",
"views/res_users.xml",
"views/cooperative_status.xml",
"wizard/instanciate_planning.xml", "wizard/instanciate_planning.xml",
"wizard/batch_template.xml", "wizard/batch_template.xml",
"wizard/assign_super_coop.xml", "wizard/assign_super_coop.xml",
"wizard/subscribe.xml",
], ],
} }

10
beesdoo_shift/data/stage.xml

@ -14,11 +14,6 @@
<field name="sequence">3</field> <field name="sequence">3</field>
<field name="color">1</field> <field name="color">1</field>
</record> </record>
<record model="beesdoo.shift.stage" id="replaced">
<field name="name">Replaced</field>
<field name="sequence">4</field>
<field name="color">5</field>
</record>
<record model="beesdoo.shift.stage" id="absent"> <record model="beesdoo.shift.stage" id="absent">
<field name="name">Absent</field> <field name="name">Absent</field>
<field name="sequence">5</field> <field name="sequence">5</field>
@ -29,6 +24,11 @@
<field name="sequence">6</field> <field name="sequence">6</field>
<field name="color">4</field> <field name="color">4</field>
</record> </record>
<record model="beesdoo.shift.stage" id="excused_necessity">
<field name="name">Excused - Absolute Necessity</field>
<field name="sequence">6</field>
<field name="color">4</field>
</record>
<record model="beesdoo.shift.stage" id="cancel"> <record model="beesdoo.shift.stage" id="cancel">
<field name="name">Cancelled</field> <field name="name">Cancelled</field>
<field name="sequence">7</field> <field name="sequence">7</field>

10
beesdoo_shift/data/system_parameter.xml

@ -0,0 +1,10 @@
<odoo noupdate="1">
<record id="seq_solucom_matricule_cabinet" model="ir.config_parameter">
<field name="key">alert_delay</field>
<field name="value">28</field>
</record>
<record id="seq_solucom_matricule_cabinet" model="ir.config_parameter">
<field name="key">default_grace_delay</field>
<field name="value">10</field>
</record>
</odoo>

2
beesdoo_shift/models/__init__.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import planning import planning
import task import task
import res_users
import cooperative_status

59
beesdoo_shift/models/cooperative_status.py

@ -0,0 +1,59 @@
# -*- coding: utf-8 -*-
from openerp import models, fields, api, _
from openerp.exceptions import ValidationError
class CooperativeStatus(models.Model):
_name = 'cooperative.status'
_rec_name = 'cooperator_id'
cooperator_id = fields.Many2one('res.partner')
info_session = fields.Boolean('Information Session ?')
info_session_date = fields.Datetime('Information Session Date')
super = fields.Boolean("Super Cooperative")
sr = fields.Integer("Compteur shift regulier")
sc = fields.Integer("Compteur shift de compensation")
time_holiday = fields.Integer("Holidays Days NB", default=0)
time_extension = fields.Integer("Extension Days NB", default=0) #Durée initial par défault sur ir_config_parameter
holiday_start_time = fields.Date("Holidays Start Day")
alert_start_time = fields.Date("Alert Start Day")
extension_start_time = fields.Date("Extension Start Day")
#Champ compute
status = fields.Selection([('ok', 'Up to Date'), ('holiday', 'Holidays'), ('alert', 'Alerte'), ('unsubscribed', 'Unsubscribed')], compute="_compute_status", string="Cooperative Status")
working_mode = fields.Selection(
[
('regular', 'Regular worker'),
('irregular', 'Irregular worker'),
('exempt', 'Exempted'),
],
string="Working mode",
)
def _compute_status(self):
for rec in self:
rec.status = 'ok'
_sql_constraints = [
('cooperator_uniq', 'unique (cooperator_id)', _('You can only set one cooperator status per cooperator')),
]
class ResPartner(models.Model):
_inherit = 'res.partner'
cooperative_status_ids = fields.One2many('cooperative.status', 'cooperator_id', readonly=True)
super = fields.Boolean(related='cooperative_status_ids.super', string="Super Cooperative", readonly=True, store=True)
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)
@api.multi
def coop_subscribe(self):
return {
'name': _('Subscribe Cooperator'),
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'beesdoo.shift.subscribe',
'target': 'new',
}
#TODO access right + vue on res.partner

4
beesdoo_shift/models/planning.py

@ -110,12 +110,14 @@ class TaskTemplate(models.Model):
tasks = self.env['beesdoo.shift.shift'] tasks = self.env['beesdoo.shift.shift']
for rec in self: for rec in self:
for i in xrange(0, rec.worker_nb): for i in xrange(0, rec.worker_nb):
worker_id = rec.worker_ids[i].id if len(rec.worker_ids) > i else False
tasks |= tasks.create({ tasks |= tasks.create({
'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), '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_template_id' : rec.id,
'task_type_id' : rec.task_type_id.id, 'task_type_id' : rec.task_type_id.id,
'super_coop_id': rec.super_coop_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,
'worker_id' : worker_id,
'is_regular': True if worker_id else False,
'start_time' : rec.start_date, 'start_time' : rec.start_date,
'end_time' : rec.end_date, 'end_time' : rec.end_date,
'stage_id': self.env.ref('beesdoo_shift.draft').id, 'stage_id': self.env.ref('beesdoo_shift.draft').id,

25
beesdoo_shift/models/res_users.py

@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
from openerp import models, fields
class ResUsers(models.Model):
_inherit = 'res.users'
super = fields.Boolean("Super Cooperative")
working_mode = fields.Selection(
[
('regular', 'Regular worker'),
('irregular', 'Irregular worker'),
('exempt', 'Exempted'),
],
string="Working mode",
)
class ResPartner(models.Model):
_inherit = 'res.partner'
super = fields.Boolean(related='user_ids.super', string="Super Cooperative", readonly=True)
working_mode = fields.Selection(
related='user_ids.working_mode',
string="Working mode",
readonly=True,
)

6
beesdoo_shift/models/task.py

@ -27,6 +27,8 @@ class Task(models.Model):
stage_id = fields.Many2one('beesdoo.shift.stage', required=True, 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') 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) color = fields.Integer(related="stage_id.color", readonly=True)
is_regular = fields.Boolean(default=False)
replaced_id = fields.Many2one('res.partner', track_visibility='onchange', domain=[('eater', '=', 'worker_eater')])
def message_auto_subscribe(self, updated_fields, values=None): def message_auto_subscribe(self, updated_fields, values=None):
self._add_follower(values) self._add_follower(values)
@ -45,4 +47,6 @@ class Task(models.Model):
_group_by_full = { _group_by_full = {
'stage_id': _read_group_stage_id, 'stage_id': _read_group_stage_id,
}
}
#TODO button to replaced someone

5
beesdoo_shift/security/group.xml

@ -14,5 +14,10 @@
<field name="category_id" ref="base.module_category_cooperative_management"/> <field name="category_id" ref="base.module_category_cooperative_management"/>
<field name="implied_ids" eval="[(4, ref('group_shift_management'))]"/> <field name="implied_ids" eval="[(4, ref('group_shift_management'))]"/>
</record> </record>
<record id="group_cooperative_admin" model="res.groups">
<field name="name">Cooperative Admin</field>
<field name="category_id" ref="base.module_category_cooperative_management"/>
<field name="implied_ids" eval="[(4, ref('group_planning_management'))]"/>
</record>
</data> </data>
</odoo> </odoo>

3
beesdoo_shift/security/ir.model.access.csv

@ -6,9 +6,12 @@ access_coopplanning_planning,Attendance Read Planning,model_beesdoo_shift_planni
access_coopplanning_task_template,Attendance Read Template,model_beesdoo_shift_template,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,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 access_coopplanning_task_full,Shift Management all Shift,model_beesdoo_shift_shift,group_shift_management,1,1,1,1
access_coop_status,Coop Status Read for all,model_cooperative_status,,1,0,0,0
access_coop_status_all,Coop Status Admin,model_cooperative_status,group_cooperative_admin,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_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_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_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_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_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 all_config_coopplanning_task,Attendance Edit Shift,model_beesdoo_shift_shift,group_planning_management,1,1,1,1

82
beesdoo_shift/views/cooperative_status.xml

@ -0,0 +1,82 @@
<odoo>
<record model="ir.ui.view" id="super_coop_partner_inherited_view_form">
<field name="name">Partner Super Coop</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="beesdoo_base.beesdoo_partner_form_view" />
<field name="arch" type="xml">
<xpath expr="//sheet" position="before">
<header>
<button name="coop_subscribe" string="Subscribe to shift" class="oe_highlight"
type="object" groups="beesdoo_shift.group_shift_management"/>
</header>
</xpath>
<field name="eater" position="after">
<field name="super" />
<field name="working_mode" />
</field>
<group name="info_session" position="inside">
<field name="info_session" />
<field name="info_session_date"
attrs="{'invisible': ['|', ('info_session', '=', False)]}" />
</group>
</field>
</record>
<record model="ir.ui.view" id="coop_status_form_view">
<field name="name">Coop Status Form View</field>
<field name="model">cooperative.status</field>
<field name="arch" type="xml">
<form>
<header>
<field name="status" widget="statusbar" />
</header>
<group>
<field name="cooperator_id" />
<field name="info_session" />
<field name="info_session_date" />
<field name="working_mode" />
<field name="super" />
<field name="sr" />
<field name="sc" />
<field name="time_holiday" />
<field name="time_extension" />
<field name="holiday_start_time" />
<field name="alert_start_time" />
<field name="extension_start_time" />
</group>
</form>
</field>
</record>
<record model="ir.ui.view" id="coop_status_tree_view">
<field name="name">Coop Status Tree view</field>
<field name="model">cooperative.status</field>
<field name="arch" type="xml">
<tree>
<field name="cooperator_id" />
<field name="super" />
<field name="sr" />
<field name="sc" />
<field name="time_holiday" />
<field name="time_extension" />
<field name="holiday_start_time" />
<field name="alert_start_time" />
<field name="extension_start_time" />
<field name="status" widget="statusbar" />
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_coop_status">
<field name="name">Cooperator Status</field>
<field name="res_model">cooperative.status</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem name="Status" id="menu_status_top" parent="menu_root"
groups="beesdoo_shift.group_shift_management" sequence="20" />
<menuitem name="Cooperative Status" id="menu_status" parent="menu_status_top"
action="action_coop_status" groups="beesdoo_shift.group_cooperative_admin" />
</odoo>

29
beesdoo_shift/views/res_users.xml

@ -1,29 +0,0 @@
<odoo>
<record model="ir.ui.view" id="super_coop_users_inherited_view_form">
<field name="name">Users Super Coop</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form" />
<field name="arch" type="xml">
<field name="partner_id" position="after">
<field name="super" />
<field name="working_mode" />
</field>
</field>
</record>
<record model="ir.ui.view" id="super_coop_partner_inherited_view_form">
<field name="name">Partner Super Coop</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="beesdoo_base.beesdoo_partner_form_view" />
<field name="arch" type="xml">
<field name="eater" position="after">
<field name="working_mode" />
<field name="super" />
</field>
</field>
</record>
</odoo>

6
beesdoo_shift/views/task.xml

@ -91,6 +91,8 @@
<field name="task_type_id" /> <field name="task_type_id" />
<field name="super_coop_id" /> <field name="super_coop_id" />
<field name="worker_id" /> <field name="worker_id" />
<field name="replaced_id" />
<field name="is_regular" />
</group> </group>
<group> <group>
<field name="start_time" /> <field name="start_time" />
@ -118,6 +120,7 @@
<field name="stage_id" /> <field name="stage_id" />
<field name="worker_id" /> <field name="worker_id" />
<field name="super_coop_id" /> <field name="super_coop_id" />
<field name="is_regular" />
<templates> <templates>
<t t-name="kanban-box"> <t t-name="kanban-box">
<div <div
@ -163,6 +166,9 @@
Super Coop: Super Coop:
<field name="super_coop_id" /> <field name="super_coop_id" />
</div> </div>
<div t-if="record.is_regular.raw_value" >
Regular Shift
</div>
</div> </div>
</div> </div>

3
beesdoo_shift/wizard/__init__.py

@ -1,3 +1,4 @@
import instanciate_planning import instanciate_planning
import batch_template import batch_template
import assign_super_coop
import assign_super_coop
import subscribe

55
beesdoo_shift/wizard/subscribe.py

@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
from openerp import models, fields, api, _
from openerp.exceptions import UserError
class Subscribe(models.TransientModel):
_name = 'beesdoo.shift.subscribe'
def _get_date(self):
date = self.env['res.partner'].browse(self._context.get('active_id')).info_session_date
if not date:
return fields.Date.today()
else:
return date
def _get_super(self):
return self.env['res.partner'].browse(self._context.get('active_id')).super
cooperator_id = fields.Many2one('res.partner', default=lambda self: self.env['res.partner'].browse(self._context.get('active_id')), required=True)
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)
working_mode = fields.Selection(
[
('regular', 'Regular worker'),
('irregular', 'Irregular worker'),
('exempt', 'Exempted'),
],
)
shift_id = fields.Many2one('beesdoo.shift.template')
@api.multi
def subscribe(self):
if not self.env.user.has_group('beesdoo_shift.group_shift_management'):
raise UserError(_("You don't have the required access for this operation."))
if self.cooperator_id == self.env.user.partner_id and not self.env.user.has_group('beesdoo_shift.group_cooperative_admin'):
raise UserError(_("You cannot subscribe yourself."))
self.ensure_one()
if self.shift_id and self.shift_id.remaining_worker <= 0:
raise UserError(_('There is no remaining space for this shift'))
if self.shift_id:
self.sudo().shift_id.worker_ids |= self.cooperator_id
data = {
'info_session' : self.info_session,
'info_session_date': self.info_session_date,
'working_mode' : self.working_mode,
'super' : self.super,
'cooperator_id': self.cooperator_id.id,
'sr' : 0, #set back to 0 if you subscribe a second time
}
status_id = self.env['cooperative.status'].search([('cooperator_id', '=', self.cooperator_id.id)])
if status_id:
status_id.sudo().write(data)
else:
self.env['cooperative.status'].sudo().create(data)

24
beesdoo_shift/wizard/subscribe.xml

@ -0,0 +1,24 @@
<odoo>
<record model="ir.ui.view" id="subscribe_coop_wizard_view_form">
<field name="name">Subscribre Cooperator</field>
<field name="model">beesdoo.shift.subscribe</field>
<field name="arch" type="xml">
<form>
<group>
<field name="cooperator_id" />
<field name="info_session" />
<field name="info_session_date" />
<field name="working_mode" />
<field name="shift_id" domain="[('remaining_worker', '>', 0)]" attrs="{'invisible': [('working_mode', '!=', 'regular')]}"/>
<field name="super" />
</group>
<footer>
<button type="object" name="subscribe"
string="Confirm" class="oe_highlight" />
or
<button special="cancel" string="Cancel" />
</footer>
</form>
</field>
</record>
</odoo>
Loading…
Cancel
Save