Browse Source

[WIP]

pull/19/head
Thibault Francois 8 years ago
parent
commit
a2b7c8bf60
  1. 1
      beesdoo_shift/__openerp__.py
  2. 26
      beesdoo_shift/models/cooperative_status.py
  3. 3
      beesdoo_shift/security/ir.model.access.csv
  4. 2
      beesdoo_shift/views/cooperative_status.xml
  5. 21
      beesdoo_shift/views/exempt_reason.xml
  6. 2
      beesdoo_shift/wizard/subscribe.py
  7. 1
      beesdoo_shift/wizard/subscribe.xml

1
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",

26
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):

3
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

2
beesdoo_shift/views/cooperative_status.xml

@ -20,6 +20,7 @@
</group>
<group>
<field name="working_mode" />
<field name="exempt_reason_id" attrs="{'invisible':[('working_mode', '!=', 'exempt')]}"/>
<field name="super" />
</group>
</group>
@ -42,6 +43,7 @@
<field name="info_session" />
<field name="info_session_date" />
<field name="working_mode" />
<field name="exempt_reason_id" attrs="{'invisible':[('working_mode', '!=', 'exempt')]}"/>
<field name="super" />
<field name="sr" />
<field name="sc" />

21
beesdoo_shift/views/exempt_reason.xml

@ -0,0 +1,21 @@
<odoo>
<record model="ir.ui.view" id="exempt_reason_tree_view">
<field name="name">Exempt Reason Tree view</field>
<field name="model">cooperative.exempt.reason</field>
<field name="arch" type="xml">
<tree editable="top">
<field name="name" />
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_exempt_reason">
<field name="name">Exempt Reason</field>
<field name="res_model">cooperative.exempt.reason</field>
<field name="view_mode">tree</field>
</record>
<menuitem name="Exempt Reason" id="menu_exempt_reason" parent="menu_status_top"
action="action_exempt_reason" groups="beesdoo_shift.group_cooperative_admin" />
</odoo>

2
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

1
beesdoo_shift/wizard/subscribe.xml

@ -9,6 +9,7 @@
<field name="info_session" />
<field name="info_session_date" />
<field name="working_mode" />
<field name="exempt_reason_id" attrs="{'invisible':[('working_mode', '!=', 'exempt')]}"/>
<field name="shift_id" domain="[('remaining_worker', '>', 0)]" attrs="{'invisible': [('working_mode', '!=', 'regular')]}"/>
<field name="super" />
</group>

Loading…
Cancel
Save