Browse Source

[CHG] b_shift : shift status

To give better understanding of compensations given by each status.

'stage_id' is replaced by a selection field state to ease
domain restrictions.
pull/143/head
Elouan Le Bars 4 years ago
parent
commit
da8c38574a
  1. 12
      beesdoo_website_shift/controllers/main.py
  2. 30
      beesdoo_website_shift/views/my_shift_website_templates.xml

12
beesdoo_website_shift/controllers/main.py

@ -143,14 +143,12 @@ class WebsiteShiftController(http.Controller):
# Get config
irregular_enable_sign_up = literal_eval(request.env['ir.config_parameter'].get_param(
'beesdoo_website_shift.irregular_enable_sign_up'))
# Get open status
open_status = request.env.ref('beesdoo_shift.open')
request.session['success'] = False
if (irregular_enable_sign_up
and self.user_can_subscribe()
and shift
and shift.stage_id == open_status
and shift.state == "open"
and not shift.worker_id):
shift.worker_id = cur_user.partner_id
request.session['success'] = True
@ -280,11 +278,10 @@ class WebsiteShiftController(http.Controller):
# Get all the shifts in the future with no worker
now = datetime.now()
open_status = request.env.ref('beesdoo_shift.open')
shifts = request.env['beesdoo.shift.shift'].sudo().search(
[('start_time', '>', now.strftime("%Y-%m-%d %H:%M:%S")),
('worker_id', '=', False),
('stage_id', '=', open_status.id)],
('state', '=', 'open')],
order="start_time, task_template_id, task_type_id",
)
@ -394,9 +391,6 @@ class WebsiteShiftController(http.Controller):
regular_next_shift_limit = int(request.env['ir.config_parameter'].get_param(
'beesdoo_website_shift.regular_next_shift_limit'))
# Get default status for fictive shifts
draft_status = request.env.ref('beesdoo_shift.draft')
for i in range(nb_subscribed_shifts, regular_next_shift_limit):
# Create the fictive shift
shift = main_shift.new()
@ -405,7 +399,7 @@ class WebsiteShiftController(http.Controller):
shift.planning_id = main_shift.planning_id
shift.task_type_id = main_shift.task_type_id
shift.worker_id = main_shift.worker_id
shift.stage_id = draft_status
shift.state = "draft"
shift.super_coop_id = main_shift.super_coop_id
shift.color = main_shift.color
shift.is_regular = main_shift.is_regular

30
beesdoo_website_shift/views/my_shift_website_templates.xml

@ -101,34 +101,34 @@
id="shift_status_label"
name="Shift Status Label">
<span t-if="shift.stage_id.code == 'draft'"
<span t-if="shift.state == 'draft'"
t-attf-class="label label-default {{label_css}}">
<t t-esc="shift.stage_id.name"/>
<t t-esc="shift.state"/>
</span>
<span t-if="shift.stage_id.code == 'done'"
<span t-if="shift.state == 'done'"
t-attf-class="label label-success {{label_css}}">
<t t-esc="shift.stage_id.name"/>
<t t-esc="shift.state"/>
</span>
<span t-if="shift.stage_id.code == 'absent'"
<span t-if="shift.state == 'absent_2'"
t-attf-class="label label-warning {{label_css}}">
<t t-esc="shift.stage_id.name"/>
<t t-esc="shift.state"/>
</span>
<span t-if="shift.stage_id.code == 'excused'"
<span t-if="shift.state == 'absent_1'"
t-attf-class="label label-info {{label_css}}">
<t t-esc="shift.stage_id.name"/>
<t t-esc="shift.state"/>
</span>
<span t-if="shift.stage_id.code == 'excused_necessity'"
<span t-if="shift.state == 'absent_0'"
t-attf-class="label label-info {{label_css}}">
<t t-esc="shift.stage_id.name"/>
<t t-esc="shift.state"/>
</span>
<span t-if="shift.stage_id.code == 'cancel'"
<span t-if="shift.state == 'cancel'"
t-attf-class="label label-danger {{label_css}}">
<t t-esc="shift.stage_id.name"/>
<t t-esc="shift.state"/>
</span>
</template>
@ -207,7 +207,7 @@
</thead>
<tbody>
<t t-foreach="subscribed_shifts" t-as="shift">
<tr t-att-class="'danger text-danger' if shift.stage_id.code == 'cancel' else ''">
<tr t-att-class="'danger text-danger' if shift.state == 'cancel' else ''">
<td>
<t t-esc="time.strftime('%A', time.strptime(shift.start_time, '%Y-%m-%d %H:%M:%S'))"/>
</td>
@ -222,7 +222,7 @@
<t t-esc="shift.task_type_id.name"/>
</td>
<td>
<t t-esc="shift.stage_id.name"/>
<t t-esc="shift.state"/>
</td>
<td class="text-center">
<button type="button" class="btn btn-default btn-sm"
@ -347,7 +347,7 @@
<t t-esc="shift.task_type_id.name"/>
</td>
<td>
<t t-esc="shift.stage_id.name"/>
<t t-esc="shift.state"/>
</td>
</tr>
</t>

Loading…
Cancel
Save