Browse Source

[ADD] beesdoo_shift: Future alert date

pull/105/head
Rémy Taymans 6 years ago
committed by Elouan
parent
commit
604b74a2dc
  1. 16
      beesdoo_shift/models/cooperative_status.py
  2. 9
      beesdoo_shift/views/cooperative_status.xml

16
beesdoo_shift/models/cooperative_status.py

@ -7,6 +7,7 @@ import logging
from openerp.osv.fields import related
_logger = logging.getLogger(__name__)
PERIOD = 28 # TODO: use system parameter
def add_days_delta(date_from, days_delta):
if not date_from:
@ -76,6 +77,7 @@ class CooperativeStatus(models.Model):
irregular_start_date = fields.Date() #TODO migration script
irregular_absence_date = fields.Date()
irregular_absence_counter = fields.Integer() #TODO unsubscribe when reach -2
future_alert_date = fields.Date(compute='_compute_future_alert_date')
temporary_exempt_reason_id = fields.Many2one('cooperative.exempt.reason', 'Exempt Reason')
temporary_exempt_start_date = fields.Date()
@ -110,6 +112,18 @@ class CooperativeStatus(models.Model):
rec.status = 'ok'
rec.can_shop = True
@api.depends('today', 'irregular_start_date', 'sr')
def _compute_future_alert_date(self):
"""Compute date before which the worker is up to date"""
for rec in self:
future_alert_date = False
if not rec.alert_start_time and rec.irregular_start_date:
today_date = fields.Date.from_string(rec.today)
delta = (today_date - fields.Date.from_string(rec.irregular_start_date)).days
future_alert_date = today_date + timedelta(days=(rec.sr + 1) * PERIOD - delta % PERIOD)
future_alert_date = future_alert_date.strftime('%Y-%m-%d')
rec.future_alert_date = future_alert_date
def _set_regular_status(self, grace_delay, alert_delay):
self.ensure_one()
ok = self.sr >= 0 and self.sc >= 0
@ -266,7 +280,7 @@ class CooperativeStatus(models.Model):
if status.status == 'exempted':
continue
delta = (today_date - fields.Date.from_string(status.irregular_start_date)).days
if delta and delta % 28 == 0 and status not in journal.line_ids: #TODO use system parameter for 28
if delta and delta % PERIOD == 0 and status not in journal.line_ids:
if status.sr > 0:
status.sr -= 1
else:

9
beesdoo_shift/views/cooperative_status.xml

@ -70,7 +70,7 @@
<field name="working_mode" />
<field name="irregular_start_date" attrs="{'invisible':[('working_mode', '!=', 'irregular')]}" />
<field name="irregular_absence_date" attrs="{'invisible':[('working_mode', '!=', 'irregular')]}" />
<field name="exempt_reason_id" attrs="{'invisible':[('working_mode', '!=', 'exempt')]}"/>
</group>
<group string="Counter and Status">
@ -84,6 +84,7 @@
<field name="can_shop" />
</group>
<group string="Timing information">
<field name="future_alert_date" readonly="1" />
<field name="time_extension" />
<field name="holiday_start_time" />
<field name="holiday_end_time" />
@ -132,7 +133,7 @@
</tree>
</field>
</record>
<record model="ir.ui.view" id="journal_form_view">
<field name="name">Journal Form View</field>
<field name="model">beesdoo.shift.journal</field>
@ -179,13 +180,13 @@
sequence="1" />
<menuitem name="Worker" id="menu_worker" parent="menu_worker_top"
action="action_worker" />
<record model="ir.actions.act_window" id="action_journal">
<field name="name">Counter Journal</field>
<field name="res_model">beesdoo.shift.journal</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem name="Counter Update Journal" id="menu_journal" parent="menu_status_top"
action="action_journal" groups="beesdoo_shift.group_cooperative_admin" />
</odoo>

Loading…
Cancel
Save