forked from Yaltik/golem
correction des bugs au niveau de la fonction de confirmation d'une reservation
This commit is contained in:
parent
e52c9028fa
commit
2a5c426bb2
@ -183,7 +183,8 @@ class GolemResourceReservation(models.Model):
|
|||||||
# Check if reservation is not taking place out the avaibility timetables
|
# Check if reservation is not taking place out the avaibility timetables
|
||||||
date_start = fields.Datetime.from_string(reservation.date_start)
|
date_start = fields.Datetime.from_string(reservation.date_start)
|
||||||
date_stop = fields.Datetime.from_string(reservation.date_stop)
|
date_stop = fields.Datetime.from_string(reservation.date_stop)
|
||||||
reservation_period = [date_start + timedelta(days=x) for x in range((date_stop - date_start).days +1)]
|
reservation_period = [date_start + timedelta(days=x) for x in range(
|
||||||
|
(date_stop - date_start).days +1)]
|
||||||
for reservation_day in reservation_period:
|
for reservation_day in reservation_period:
|
||||||
is_day_allowed = False
|
is_day_allowed = False
|
||||||
for timetable in reservation.resource_id.timetable_ids:
|
for timetable in reservation.resource_id.timetable_ids:
|
||||||
@ -195,28 +196,31 @@ class GolemResourceReservation(models.Model):
|
|||||||
if not timetable.availibility_24:
|
if not timetable.availibility_24:
|
||||||
hour_start = 0.0
|
hour_start = 0.0
|
||||||
hour_stop = 0.0
|
hour_stop = 0.0
|
||||||
if (reservation_day == date_start and
|
if (reservation_day.date() == date_start.date() and
|
||||||
reservation_day == date_stop):
|
reservation_day.date() == date_stop.date()):
|
||||||
hour_start = date_start.hour + date_start.minute/60.0
|
hour_start = date_start.hour + date_start.minute/60.0
|
||||||
hour_stop = date_stop.hour + date_stop.minute/60.0
|
hour_stop = date_stop.hour + date_stop.minute/60.0
|
||||||
elif (reservation_day == date_start and
|
elif reservation_day.date() == date_start.date():
|
||||||
reservation_day != date_stop):
|
|
||||||
hour_start = date_start.hour + date_start.minute/60.0
|
hour_start = date_start.hour + date_start.minute/60.0
|
||||||
hour_stop = 23.98
|
hour_stop = 23.98
|
||||||
elif (reservation_day == date_stop and
|
elif reservation_day.date() == date_stop.date():
|
||||||
reservation_day != date_start):
|
|
||||||
hour_start = 0.0
|
hour_start = 0.0
|
||||||
hour_stop = date_stop.hour + date_stop.minute/60.0
|
hour_stop = date_stop.hour + date_stop.minute/60.0
|
||||||
|
else:
|
||||||
|
#if the day is not a start nor stop it's not allowed unless
|
||||||
|
#availibility_24 is True
|
||||||
|
is_day_allowed = False
|
||||||
|
|
||||||
if hour_start < timetable.time_start or \
|
if is_day_allowed and (hour_start < timetable.time_start or \
|
||||||
hour_stop > timetable.time_stop:
|
hour_stop > timetable.time_stop):
|
||||||
verr = _('Not allowed, the resource is not available '
|
verr = _('Not allowed, the resource is not available '
|
||||||
'during this period, please choose another '
|
'during this schedule, please choose another '
|
||||||
'time before confirming.')
|
'time before confirming.')
|
||||||
raise ValidationError(verr)
|
raise ValidationError(verr)
|
||||||
if not is_day_allowed:
|
if not is_day_allowed:
|
||||||
verr = _('Not allowed, the resource is not available '
|
verr = _('Not allowed, the resource is not available '
|
||||||
'this day. Please choose another date.')
|
'in a day you chosed. Please choose another date.')
|
||||||
raise ValidationError(verr)
|
raise ValidationError(verr)
|
||||||
# Check if the resource is already taken during this period
|
# Check if the resource is already taken during this period
|
||||||
domain = [('resource_id', '=', reservation.resource_id.id),
|
domain = [('resource_id', '=', reservation.resource_id.id),
|
||||||
|
@ -40,15 +40,23 @@ class GolemTimetable(models.Model):
|
|||||||
time_start = fields.Float(required=True, string='Start')
|
time_start = fields.Float(required=True, string='Start')
|
||||||
time_stop = fields.Float(required=True, string='Stop')
|
time_stop = fields.Float(required=True, string='Stop')
|
||||||
availibility_24 = fields.Boolean(string="All day")
|
availibility_24 = fields.Boolean(string="All day")
|
||||||
@api.onchange('availibility_24')
|
#@api.onchange('availibility_24')
|
||||||
def _set_time_start_stop(self):
|
#def _set_time_start_stop(self):
|
||||||
""" set start and stop time """
|
# """ set start and stop time """
|
||||||
self.ensure_one()
|
# self.ensure_one()
|
||||||
if self.availibility_24:
|
# if self.availibility_24:
|
||||||
self.time_start = 0.0
|
# self.time_start = 0.0
|
||||||
self.time_stop = 23.99
|
# self.time_stop = 23.99
|
||||||
|
|
||||||
|
|
||||||
|
@api.onchange('availibility_24')
|
||||||
|
def onchange_availibility_24(self):
|
||||||
|
""" Propose automatically stop hour after start hour had been filled """
|
||||||
|
for line in self:
|
||||||
|
if line.availibility_24:
|
||||||
|
line.time_start = 0.0
|
||||||
|
line.time_stop = 23.98
|
||||||
|
|
||||||
@api.onchange('time_start')
|
@api.onchange('time_start')
|
||||||
def onchange_time_start(self):
|
def onchange_time_start(self):
|
||||||
""" Propose automatically stop hour after start hour had been filled """
|
""" Propose automatically stop hour after start hour had been filled """
|
||||||
|
@ -28,10 +28,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name="resource_id" invisible="1" />
|
<field name="resource_id" invisible="1" />
|
||||||
<field name="weekday" />
|
<field name="weekday" />
|
||||||
<field name="availibility_24"/>
|
<field name="availibility_24"/>
|
||||||
<field name="time_start" string="Start hour" widget="float_time"
|
<field name="time_start" string="Start hour" widget="float_time"/>
|
||||||
attrs="{'readonly': [('availibility_24', '=', True)]}"/>
|
<field name="time_stop" string="Stop hour" widget="float_time"/>
|
||||||
<field name="time_stop" string="Stop hour" widget="float_time"
|
|
||||||
attrs="{'readonly': [('availibility_24', '=', True)]}"/>
|
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user