forked from Yaltik/golem
depasser la verification du jours et heurs en cas de disponibilité total
This commit is contained in:
parent
5163b7535c
commit
b3705b95ef
@ -169,23 +169,25 @@ class GolemResourceReservation(models.Model):
|
|||||||
'this period, please choose another périod before '
|
'this period, please choose another périod before '
|
||||||
'confirming')
|
'confirming')
|
||||||
raise ValidationError(verr)
|
raise ValidationError(verr)
|
||||||
# Check if reservation is not taking place out the avaibility timetables
|
#check if the resource hasn't a total availibility
|
||||||
is_day_allowed = False
|
if not reservation.resource_id.availibility_24_7:
|
||||||
for timetable in reservation.resource_id.timetable_ids:
|
# Check if reservation is not taking place out the avaibility timetables
|
||||||
# Check for the time according to resource timetable avaibility
|
is_day_allowed = False
|
||||||
date = fields.Datetime.from_string(reservation.date)
|
for timetable in reservation.resource_id.timetable_ids:
|
||||||
if int(timetable.weekday) == date.weekday():
|
# Check for the time according to resource timetable avaibility
|
||||||
is_day_allowed = True
|
date = fields.Datetime.from_string(reservation.date)
|
||||||
if reservation.hour_start < timetable.time_start or \
|
if int(timetable.weekday) == date.weekday():
|
||||||
reservation.hour_stop > timetable.time_stop:
|
is_day_allowed = True
|
||||||
verr = _('Not allowed, the resource is not available '
|
if reservation.hour_start < timetable.time_start or \
|
||||||
'during this period, please choose another '
|
reservation.hour_stop > timetable.time_stop:
|
||||||
'time before confirming.')
|
verr = _('Not allowed, the resource is not available '
|
||||||
raise ValidationError(verr)
|
'during this period, please choose another '
|
||||||
if not is_day_allowed:
|
'time before confirming.')
|
||||||
verr = _('Not allowed, the resource is not available '
|
raise ValidationError(verr)
|
||||||
'this day. Please choose another date.')
|
if not is_day_allowed:
|
||||||
raise ValidationError(verr)
|
verr = _('Not allowed, the resource is not available '
|
||||||
|
'this day. Please choose another date.')
|
||||||
|
raise ValidationError(verr)
|
||||||
# Check if the resource is already taken during this period
|
# Check if the resource is already taken during this period
|
||||||
# PERF : check the date, not iterate over all reservations
|
# PERF : check the date, not iterate over all reservations
|
||||||
domain = [('resource_id', '=', reservation.resource_id.id),
|
domain = [('resource_id', '=', reservation.resource_id.id),
|
||||||
@ -203,7 +205,7 @@ class GolemResourceReservation(models.Model):
|
|||||||
other_res.date_stop))
|
other_res.date_stop))
|
||||||
@api.multi
|
@api.multi
|
||||||
def reservation_calendar(self):
|
def reservation_calendar(self):
|
||||||
""" current resource reservation list """
|
""" current resource reservation calendar """
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
calendar_view = {
|
calendar_view = {
|
||||||
'name': ('Resource Reservation list'),
|
'name': ('Resource Reservation list'),
|
||||||
|
Loading…
Reference in New Issue
Block a user