Skip to content

Commit

Permalink
Merge pull request #331 from beescoop/12.0-fix-my-next-shifts-display
Browse files Browse the repository at this point in the history
[FIX] b_website_shift: fix the future shifts display on "My shifts" webpage
  • Loading branch information
remytms authored Apr 14, 2022
2 parents 5152bfc + 723d0d3 commit eea27f1
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions beesdoo_website_shift/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(1, regular_next_shift_limit - len(subscribed_shifts) + 1):
# Create the fictive shift
shift = main_shift.new()
shift.name = main_shift.name
Expand Down

0 comments on commit eea27f1

Please sign in to comment.