Browse Source

[FIX] b_website_shift: cancelled shift

Stop showing cancelled shift in available shift list.
pull/128/head
Rémy Taymans 6 years ago
parent
commit
b05371a085
  1. 8
      beesdoo_website_shift/controllers/main.py

8
beesdoo_website_shift/controllers/main.py

@ -100,6 +100,7 @@ class WebsiteShiftController(http.Controller):
* shift sign up is authorised via configuration panel * shift sign up is authorised via configuration panel
* the current connected user is an irregular worker * the current connected user is an irregular worker
* the given shift exist * the given shift exist
* the shift status is open
* the shift is free for subscription * the shift is free for subscription
""" """
# Get current user # Get current user
@ -109,11 +110,14 @@ class WebsiteShiftController(http.Controller):
# Get config # Get config
irregular_enable_sign_up = literal_eval(request.env['ir.config_parameter'].get_param( irregular_enable_sign_up = literal_eval(request.env['ir.config_parameter'].get_param(
'beesdoo_website_shift.irregular_enable_sign_up')) 'beesdoo_website_shift.irregular_enable_sign_up'))
# Get open status
open_status = request.env.ref('beesdoo_shift.open')
request.session['success'] = False request.session['success'] = False
if (irregular_enable_sign_up if (irregular_enable_sign_up
and cur_user.partner_id.working_mode == 'irregular' and cur_user.partner_id.working_mode == 'irregular'
and shift and shift
and shift.status_id == open_status
and not shift.worker_id): and not shift.worker_id):
shift.worker_id = cur_user.partner_id shift.worker_id = cur_user.partner_id
request.session['success'] = True request.session['success'] = True
@ -219,9 +223,11 @@ class WebsiteShiftController(http.Controller):
# 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()
open_status = request.env.ref('beesdoo_shift.open')
shifts = request.env['beesdoo.shift.shift'].sudo().search( shifts = request.env['beesdoo.shift.shift'].sudo().search(
[('start_time', '>', now.strftime("%Y-%m-%d %H:%M:%S")), [('start_time', '>', now.strftime("%Y-%m-%d %H:%M:%S")),
('worker_id', '=', False)],
('worker_id', '=', False),
('stage_id', '=', open_status.id)],
order="start_time, task_template_id, task_type_id", order="start_time, task_template_id, task_type_id",
) )

Loading…
Cancel
Save