Commit a381cc47 by Damien Moulard

Merge branch 'evolution_bdm' of…

Merge branch 'evolution_bdm' of gl.cooperatic.fr:cooperatic-foodcoops/third-party into evolution_bdm
parents 4ddae949 26fc2d5d
......@@ -1142,6 +1142,12 @@ class CagetteServices(models.Model):
# let authorized people time to set presence for those who came in late
end_date = now - datetime.timedelta(hours=3)
api = OdooAPI()
absence_status = 'excused'
res_c = api.search_read('ir.config_parameter',
[['key', '=', 'lacagette_membership.absence_status']],
['value'])
if len(res_c) == 1:
absence_status = res_c[0]['value']
cond = [['date_begin', '>=', date_24h_before.isoformat()],
['date_begin', '<=', end_date.isoformat()],
['state', '=', 'open']]
......@@ -1165,7 +1171,7 @@ class CagetteServices(models.Model):
(_h, _m, _s) = h.split(':')
if int(_h) < 21:
ids.append(int(r['id']))
f = {'state': 'excused'}
f = {'state': absence_status}
return {'update': api.update('shift.registration', ids, f), 'reg_shift': res}
@staticmethod
......
......@@ -242,7 +242,7 @@ class CagetteShift(models.Model):
for val in extension_types:
if val['name'] == 'Extension':
ext_type_id = val['id']
starting_date = datetime.datetime.strptime(data['start_date'], '%Y-%m-%d').date()
ending_date = (starting_date + datetime.timedelta(days=duration))
......
......@@ -246,11 +246,9 @@ def request_delay(request):
}
if ('extension_beginning' in request.POST):
data['extension_beginning'] = request.POST['extension_beginning']
duration = 28
if ('duration' in request.POST):
duration = int(request.POST['duration'])
else:
duration = None
response = {'result': False}
......@@ -259,8 +257,10 @@ def request_delay(request):
if (new_id):
response = {'result': True}
else:
coop_logger.error("request delay : %s, %s", str(new_id), str(data))
return HttpResponseServerError()
except Exception as e:
coop_logger.error("request delay : %s, %s", str(e), str(data))
return HttpResponseServerError()
return JsonResponse(response)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment