forked from Yaltik/golem
Derniere version de multidays avant mise à jours master
This commit is contained in:
parent
f9ba4284c8
commit
395a4becdb
@ -56,6 +56,8 @@ class GolemResourceReservation(models.Model):
|
|||||||
states={'draft': [('readonly', False)]})
|
states={'draft': [('readonly', False)]})
|
||||||
resource_avaibility_start = fields.Date(related='resource_id.avaibility_start')
|
resource_avaibility_start = fields.Date(related='resource_id.avaibility_start')
|
||||||
resource_avaibility_stop = fields.Date(related='resource_id.avaibility_stop')
|
resource_avaibility_stop = fields.Date(related='resource_id.avaibility_stop')
|
||||||
|
resource_availibility_24_7 = fields.Boolean(related='resource_id.availibility_24_7')
|
||||||
|
resource_availibility_24_24 = fields.Boolean(related='resource_id.availibility_24_24')
|
||||||
resource_timetable_ids = fields.One2many(related='resource_id.timetable_ids')
|
resource_timetable_ids = fields.One2many(related='resource_id.timetable_ids')
|
||||||
|
|
||||||
note = fields.Text(help='Notes, optional subject for the reservation, reason')
|
note = fields.Text(help='Notes, optional subject for the reservation, reason')
|
||||||
@ -181,10 +183,58 @@ 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 it's a multidays reservation
|
||||||
|
res_date_start = fields.Datetime.from_string(reservation.date_start).date()
|
||||||
|
res_date_stop = fields.Datetime.from_string(reservation.date_stop).date()
|
||||||
|
multidays = res_date_start != res_date_stop
|
||||||
|
|
||||||
#check if the resource hasn't a total availibility
|
#check if the resource hasn't a total availibility
|
||||||
if not reservation.resource_id.availibility_24_7:
|
if not reservation.resource_availibility_24_7:
|
||||||
|
if reservation.resource_availibility_24_24 and multidays:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
elif reservation.resource_availibility_24_24:
|
||||||
|
|
||||||
|
# Check if reservation is not taking place out the avaibility timetables
|
||||||
|
is_day_allowed = False
|
||||||
|
for timetable in reservation.resource_id.timetable_ids:
|
||||||
|
# Check for the time according to resource timetable avaibility
|
||||||
|
date = fields.Datetime.from_string(reservation.date_start)
|
||||||
|
if int(timetable.weekday) == date.weekday():
|
||||||
|
is_day_allowed = True
|
||||||
|
if not is_day_allowed:
|
||||||
|
verr = _('Not allowed, the resource is not available '
|
||||||
|
'this day. Please choose another date.')
|
||||||
|
raise ValidationError(verr)
|
||||||
|
|
||||||
|
elif not reservation.resource_availibility_24_24 and multidays:
|
||||||
|
pass
|
||||||
|
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Check if reservation is not taking place out the avaibility timetables
|
||||||
|
is_day_allowed = False
|
||||||
|
for timetable in reservation.resource_id.timetable_ids:
|
||||||
|
# Check for the time according to resource timetable avaibility
|
||||||
|
date = fields.Datetime.from_string(reservation.date_start)
|
||||||
|
if int(timetable.weekday) == date.weekday():
|
||||||
|
is_day_allowed = True
|
||||||
|
if reservation.hour_start < timetable.time_start or \
|
||||||
|
reservation.hour_stop > timetable.time_stop:
|
||||||
|
verr = _('Not allowed, the resource is not available '
|
||||||
|
'during this period, please choose another '
|
||||||
|
'time before confirming.')
|
||||||
|
raise ValidationError(verr)
|
||||||
|
if not is_day_allowed:
|
||||||
|
verr = _('Not allowed, the resource is not available '
|
||||||
|
'this day. Please choose another date.')
|
||||||
|
raise ValidationError(verr)
|
||||||
|
|
||||||
|
|
||||||
# Check if reservation is not taking place out the avaibility timetables
|
# Check if reservation is not taking place out the avaibility timetables
|
||||||
is_day_allowed = False
|
"""is_day_allowed = False
|
||||||
for timetable in reservation.resource_id.timetable_ids:
|
for timetable in reservation.resource_id.timetable_ids:
|
||||||
# Check for the time according to resource timetable avaibility
|
# Check for the time according to resource timetable avaibility
|
||||||
date = fields.Datetime.from_string(reservation.date)
|
date = fields.Datetime.from_string(reservation.date)
|
||||||
@ -199,7 +249,7 @@ class GolemResourceReservation(models.Model):
|
|||||||
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.')
|
'this day. 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
|
||||||
# PERF : check the date, not iterate over all reservations
|
# PERF : check the date, not iterate over all reservations
|
||||||
|
@ -84,9 +84,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<group string="Resource">
|
<group string="Resource">
|
||||||
<field name="id" invisible="1" />
|
<field name="id" invisible="1" />
|
||||||
<field name="resource_id" options="{'no_create': True}" />
|
<field name="resource_id" options="{'no_create': True}" />
|
||||||
|
<field name="resource_availibility_24_7" readonly="1" />
|
||||||
<field name="resource_avaibility_start" readonly="1" />
|
<field name="resource_avaibility_start" readonly="1" />
|
||||||
<field name="resource_avaibility_stop" readonly="1" />
|
<field name="resource_avaibility_stop" readonly="1" />
|
||||||
<field name="resource_timetable_ids" readonly="1" />
|
<field name="resource_timetable_ids"
|
||||||
|
attrs="{'invisible': [('resource_availibility_24_7', '=', True)]}" readonly="1" />
|
||||||
</group>
|
</group>
|
||||||
<group string="Reservation">
|
<group string="Reservation">
|
||||||
<group>
|
<group>
|
||||||
|
Loading…
Reference in New Issue
Block a user