Browse Source

[IMP] b_shift : attendance sheet generation time configurable

Generation CRON is running every minute and check for sheets
in the configurable time interval. Workers can't subscribe
to a shift on intranet if its start time is in this interval.
pull/143/head
Elouan Le Bars 5 years ago
parent
commit
4fad17af33
  1. 20
      beesdoo_website_shift/controllers/main.py
  2. 2
      beesdoo_website_shift/views/my_shift_website_templates.xml

20
beesdoo_website_shift/controllers/main.py

@ -135,7 +135,8 @@ class WebsiteShiftController(http.Controller):
* the given shift exist * the given shift exist
* the shift status is open * the shift status is open
* the shift is free for subscription * the shift is free for subscription
* the shift is starting in more than 20 minutes
* the shift is starting after the time interval
for attendance sheet generation defined in beesdoo_shift settings
""" """
# Get current user # Get current user
cur_user = request.env['res.users'].browse(request.uid) cur_user = request.env['res.users'].browse(request.uid)
@ -144,8 +145,13 @@ 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'))
# Set start time limit
start_time_limit = datetime.now() + timedelta(minutes = 20)
# Set start time limit as defined in beesdoo_shift settings
setting = int(
request.env["ir.config_parameter"].get_param(
"beesdoo_shift.attendance_sheet_generation_interval"
)
)
start_time_limit = datetime.now() + timedelta(minutes=setting)
shift_start_time = fields.Datetime.from_string(shift.start_time) shift_start_time = fields.Datetime.from_string(shift.start_time)
request.session['success'] = False request.session['success'] = False
@ -236,6 +242,14 @@ class WebsiteShiftController(http.Controller):
template_context['success'] = request.session.get('success') template_context['success'] = request.session.get('success')
del request.session['success'] del request.session['success']
# Add setting for subscription allowed time
subscription_time_limit = int(
request.env["ir.config_parameter"].get_param(
"beesdoo_shift.attendance_sheet_generation_interval"
)
)
template_context['subscription_time_limit'] = subscription_time_limit
return template_context return template_context
def my_shift_regular_worker_without_shift(self): def my_shift_regular_worker_without_shift(self):

2
beesdoo_website_shift/views/my_shift_website_templates.xml

@ -902,7 +902,7 @@
subscribed before you or the shift was deleted. Try again in a subscribed before you or the shift was deleted. Try again in a
moment. moment.
Please note that you can't subscribe 20 minutes before the shift.
Please note that you can't subscribe <t t-esc="subscription_time_limit"/> minutes before the shift.
</t> </t>
</div> </div>

Loading…
Cancel
Save