From eed784afaea024a1bd9c7a68425929fdb91736a4 Mon Sep 17 00:00:00 2001 From: MatteoLdx Date: Mon, 4 Apr 2022 15:00:10 +0200 Subject: [PATCH 1/2] [FIX] b_website_shift: determine next shifts for regular workers using usual shift instead of next one --- beesdoo_website_shift/controllers/main.py | 40 ++++++++++------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/beesdoo_website_shift/controllers/main.py b/beesdoo_website_shift/controllers/main.py index cf879144e..c2642041a 100644 --- a/beesdoo_website_shift/controllers/main.py +++ b/beesdoo_website_shift/controllers/main.py @@ -389,28 +389,24 @@ def my_shift_next_shifts(self): # according to the regular_next_shift_limit if self.is_user_regular(): # Compute main shift - nb_subscribed_shifts = len(subscribed_shifts) - if nb_subscribed_shifts > 0: - main_shift = subscribed_shifts[-1] - else: - task_template = ( - request.env["beesdoo.shift.template"] - .sudo() - .search([("worker_ids", "in", cur_user.partner_id.id)], limit=1) - ) - main_shift = ( - request.env["beesdoo.shift.shift"] - .sudo() - .search( - [ - ("task_template_id", "=", task_template[0].id), - ("start_time", "!=", False), - ("end_time", "!=", False), - ], - order="start_time desc", - limit=1, - ) + task_template = ( + request.env["beesdoo.shift.template"] + .sudo() + .search([("worker_ids", "in", cur_user.partner_id.id)], limit=1) + ) + main_shift = ( + request.env["beesdoo.shift.shift"] + .sudo() + .search( + [ + ("task_template_id", "=", task_template[0].id), + ("start_time", "!=", False), + ("end_time", "!=", False), + ], + order="start_time desc", + limit=1, ) + ) # Get config regular_next_shift_limit = request.website.regular_next_shift_limit @@ -420,7 +416,7 @@ def my_shift_next_shifts(self): .get_param("beesdoo_website_shift.shift_period") ) - for i in range(nb_subscribed_shifts, regular_next_shift_limit): + for i in range(len(subscribed_shifts), regular_next_shift_limit): # Create the fictive shift shift = main_shift.new() shift.name = main_shift.name From 723d0d3e27cd7082ec73e06447abcfa15dafdfa4 Mon Sep 17 00:00:00 2001 From: MatteoLdx Date: Thu, 7 Apr 2022 11:11:41 +0200 Subject: [PATCH 2/2] [FIX] beesdoo_website_shift: Fix missing computed shifts in /my/shift webpage --- beesdoo_website_shift/controllers/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beesdoo_website_shift/controllers/main.py b/beesdoo_website_shift/controllers/main.py index c2642041a..fde765b76 100644 --- a/beesdoo_website_shift/controllers/main.py +++ b/beesdoo_website_shift/controllers/main.py @@ -416,7 +416,7 @@ def my_shift_next_shifts(self): .get_param("beesdoo_website_shift.shift_period") ) - for i in range(len(subscribed_shifts), regular_next_shift_limit): + for i in range(1, regular_next_shift_limit - len(subscribed_shifts) + 1): # Create the fictive shift shift = main_shift.new() shift.name = main_shift.name