Browse Source
[S0047] Faire le suivi des inscriptions aux séances info/inscriptions shifts
pull/105/head
[S0047] Faire le suivi des inscriptions aux séances info/inscriptions shifts
pull/105/head
Thibault Francois
8 years ago
committed by
Elouan
16 changed files with 263 additions and 64 deletions
-
4beesdoo_shift/__openerp__.py
-
10beesdoo_shift/data/stage.xml
-
10beesdoo_shift/data/system_parameter.xml
-
2beesdoo_shift/models/__init__.py
-
59beesdoo_shift/models/cooperative_status.py
-
4beesdoo_shift/models/planning.py
-
25beesdoo_shift/models/res_users.py
-
6beesdoo_shift/models/task.py
-
5beesdoo_shift/security/group.xml
-
3beesdoo_shift/security/ir.model.access.csv
-
82beesdoo_shift/views/cooperative_status.xml
-
29beesdoo_shift/views/res_users.xml
-
6beesdoo_shift/views/task.xml
-
3beesdoo_shift/wizard/__init__.py
-
55beesdoo_shift/wizard/subscribe.py
-
24beesdoo_shift/wizard/subscribe.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> |
@ -1,4 +1,4 @@ |
|||||
# -*- coding: utf-8 -*- |
# -*- coding: utf-8 -*- |
||||
import planning |
import planning |
||||
import task |
import task |
||||
import res_users |
|
||||
|
import cooperative_status |
@ -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 |
@ -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, |
|
||||
) |
|
@ -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> |
||||
|
|
||||
|
|
@ -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> |
|
||||
|
|
||||
|
|
@ -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 |
@ -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) |
@ -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> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue