Browse Source

[IMP] website_shift: Status on personal pages

Show dates properly.
Hide what's useless.
Give meaningful name.
pull/33/head
Rémy Taymans 7 years ago
parent
commit
27c1ae53ef
  1. 15
      beesdoo_website_shift/controllers/main.py
  2. 121
      beesdoo_website_shift/views/shift_website_templates.xml

15
beesdoo_website_shift/controllers/main.py

@ -1,8 +1,9 @@
# -*- coding: utf8 -*- # -*- coding: utf8 -*-
from ast import literal_eval from ast import literal_eval
from datetime import datetime
from datetime import datetime, timedelta
from itertools import groupby from itertools import groupby
from openerp import http
from openerp import http, fields
from openerp.http import request from openerp.http import request
from openerp.addons.beesdoo_shift.models.planning import float_to_time from openerp.addons.beesdoo_shift.models.planning import float_to_time
@ -46,6 +47,7 @@ class WebsiteShiftController(http.Controller):
def shift_irregular_worker(self, **kwargs): def shift_irregular_worker(self, **kwargs):
# Get current user # Get current user
cur_user = request.env['res.users'].browse(request.uid) cur_user = request.env['res.users'].browse(request.uid)
cur_cooperative_status = cur_user.partner_id.cooperative_status_ids
# Get all the shifts in the future with no worker # Get all the shifts in the future with no worker
now = datetime.now() now = datetime.now()
@ -62,6 +64,12 @@ class WebsiteShiftController(http.Controller):
order="start_time, task_template_id, task_type_id", order="start_time, task_template_id, task_type_id",
) )
# Compute date before which the worker is up to date
today_date = fields.Date.from_string(cur_cooperative_status.today)
delta = (today_date - fields.Date.from_string(cur_cooperative_status.irregular_start_date)).days
date_before_last_shift = today_date + timedelta(days=(cur_cooperative_status.sr + 1) * 28 - delta % 28)
date_before_last_shift = date_before_last_shift.strftime('%Y-%m-%d')
# Get config # Get config
irregular_shift_limit = int(request.env['ir.config_parameter'].get_param( irregular_shift_limit = int(request.env['ir.config_parameter'].get_param(
'beesdoo_website_shift.irregular_shift_limit')) 'beesdoo_website_shift.irregular_shift_limit'))
@ -101,7 +109,8 @@ class WebsiteShiftController(http.Controller):
'beesdoo_website_shift.irregular_worker', 'beesdoo_website_shift.irregular_worker',
{ {
'partner': cur_user.partner_id, 'partner': cur_user.partner_id,
'status': cur_user.partner_id.cooperative_status_ids,
'status': cur_cooperative_status,
'date_before_last_shift': date_before_last_shift,
'shift_templates': shifts_count_subscribed, 'shift_templates': shifts_count_subscribed,
'highlight_rule': highlight_rule, 'highlight_rule': highlight_rule,
'nexturl': '/shift', 'nexturl': '/shift',

121
beesdoo_website_shift/views/shift_website_templates.xml

@ -49,7 +49,7 @@
</t> </t>
</template> </template>
<!-- Shifts Exempt Workers -->
<!-- Shifts Exempted Workers -->
<template <template
id="exempted_worker" id="exempted_worker"
name="Shifts for Exempted Workers" name="Shifts for Exempted Workers"
@ -104,24 +104,26 @@
<label>Working Mode:</label> <label>Working Mode:</label>
<t t-esc="dict(status.fields_get(allfields=['working_mode'])['working_mode']['selection'])[status.working_mode]"/> <t t-esc="dict(status.fields_get(allfields=['working_mode'])['working_mode']['selection'])[status.working_mode]"/>
</p> </p>
<p> <p>
<label>Status:</label> <label>Status:</label>
<t t-esc="dict(status.fields_get(allfields=['status'])['status']['selection'])[status.status]"/> <t t-esc="dict(status.fields_get(allfields=['status'])['status']['selection'])[status.status]"/>
</p> </p>
<p>
<p t-if="status.exempt_reason_id">
<label>Exempt Reason:</label> <label>Exempt Reason:</label>
<t t-esc="status.exempt_reason_id.name"/> <t t-esc="status.exempt_reason_id.name"/>
</p> </p>
<t t-if="status.holiday_start_time">
<p>
<label>Holiday start time:</label>
<t t-esc="status.holiday_start_time"/>
</p>
<p>
<label>Holiday end time:</label>
<t t-esc="status.holiday_end_time"/>
</p>
</t>
<p t-if="status.holiday_start_time">
<label>Holiday start time:</label>
<t t-esc="time.strftime('%A %d %B %Y', time.strptime(status.holiday_start_time, '%Y-%m-%d'))"/>
</p>
<p t-if="status.holiday_end_time">
<label>Holiday end time:</label>
<t t-esc="time.strftime('%A %d %B %Y', time.strptime(status.holiday_end_time, '%Y-%m-%d'))"/>
</p>
<div class="oe_structure"/> <div class="oe_structure"/>
@ -208,35 +210,40 @@
<label>Working Mode:</label> <label>Working Mode:</label>
<t t-esc="dict(status.fields_get(allfields=['working_mode'])['working_mode']['selection'])[status.working_mode]"/> <t t-esc="dict(status.fields_get(allfields=['working_mode'])['working_mode']['selection'])[status.working_mode]"/>
</p> </p>
<p> <p>
<label>Status:</label> <label>Status:</label>
<t t-esc="dict(status.fields_get(allfields=['status'])['status']['selection'])[status.status]"/> <t t-esc="dict(status.fields_get(allfields=['status'])['status']['selection'])[status.status]"/>
</p> </p>
<p>
<label>Regular Shift Counter:</label>
<p t-if="status.sr != 0">
<label>Shift in Advance:</label>
<t t-esc="status.sr"/> <t t-esc="status.sr"/>
</p> </p>
<p>
<label>Compensation Shift Counter:</label>
<p t-if="status.sc != 0">
<label>Compensation Shift:</label>
<t t-esc="status.sc"/> <t t-esc="status.sc"/>
</p> </p>
<t t-if="status.holiday_start_time">
<p>
<label>Holiday start time:</label>
<t t-esc="status.holiday_start_time"/>
</p>
<p>
<label>Holiday end time:</label>
<t t-esc="status.holiday_end_time"/>
</p>
</t>
<p>
<label>Alert start date:</label>
<t t-esc="status.alert_start_time"/>
<p t-if="status.holiday_start_time">
<label>Begining of Holiday:</label>
<t t-esc="time.strftime('%A %d %B %Y', time.strptime(status.holiday_start_time, '%Y-%m-%d'))"/>
</p> </p>
<p>
<label>Extension start date:</label>
<t t-esc="status.extension_start_time"/>
<p t-if="status.holiday_end_time">
<label>End of Holiday:</label>
<t t-esc="time.strftime('%A %d %B %Y', time.strptime(status.holiday_end_time, '%Y-%m-%d'))"/>
</p>
<p t-if="status.alert_start_time">
<label>In Alert Since:</label>
<t t-esc="time.strftime('%A %d %B %Y', time.strptime(status.alert_start_time, '%Y-%m-%d'))"/>
</p>
<p t-if="status.extension_start_time">
<label>In Extension Since:</label>
<t t-esc="time.strftime('%A %d %B %Y', time.strptime(status.extension_start_time, '%Y-%m-%d'))"/>
</p> </p>
<div class="oe_structure"/> <div class="oe_structure"/>
@ -469,36 +476,40 @@
<label>Working Mode:</label> <label>Working Mode:</label>
<t t-esc="dict(status.fields_get(allfields=['working_mode'])['working_mode']['selection'])[status.working_mode]"/> <t t-esc="dict(status.fields_get(allfields=['working_mode'])['working_mode']['selection'])[status.working_mode]"/>
</p> </p>
<p> <p>
<label>Status:</label> <label>Status:</label>
<t t-esc="dict(status.fields_get(allfields=['status'])['status']['selection'])[status.status]"/> <t t-esc="dict(status.fields_get(allfields=['status'])['status']['selection'])[status.status]"/>
</p> </p>
<p> <p>
<label>Absence Counter:</label>
<t t-esc="status.irregular_absence_counter"/>
<label>Shift in Advance:</label>
<t t-esc="status.sr"/>
</p> </p>
<t t-if="status.holiday_start_time">
<p>
<label>Holiday start time:</label>
<t t-esc="status.holiday_start_time"/>
</p>
<p>
<label>Holiday end time:</label>
<t t-esc="status.holiday_end_time"/>
</p>
</t>
<p>
<label>Irregular start date:</label>
<t t-esc="status.irregular_start_date"/>
<p t-if="date_before_last_shift">
<label>Date Before Last Shift:</label>
<t t-esc="time.strftime('%A %d %B %Y', time.strptime(date_before_last_shift, '%Y-%m-%d'))"/>
</p> </p>
<p>
<label>Irregular absence date:</label>
<t t-if="status.irregular_absence_date">
<t t-esc="status.irregular_absence_date"/>
</t>
<t t-if="not status.irregular_absence_date">
No absence
</t>
<p t-if="status.holiday_start_time">
<label>Begining of Holiday:</label>
<t t-esc="time.strftime('%A %d %B %Y', time.strptime(status.holiday_start_time, '%Y-%m-%d'))"/>
</p>
<p t-if="status.holiday_end_time">
<label>End of Holiday:</label>
<t t-esc="time.strftime('%A %d %B %Y', time.strptime(status.holiday_end_time, '%Y-%m-%d'))"/>
</p>
<p t-if="status.irregular_absence_date">
<label>Last Absence Date:</label>
<t t-esc="time.strftime('%A %d %B %Y', time.strptime(status.irregular_absence_date, '%Y-%m-%d'))"/>
</p>
<p t-if="status.irregular_absence_counter">
<label>Number of Absence:</label>
<t t-esc="status.irregular_absence_counter"/>
</p> </p>
<div class="oe_structure"/> <div class="oe_structure"/>

Loading…
Cancel
Save