fix availability spelling mistake

This commit is contained in:
Youssef Elouahby 2018-08-02 18:43:58 +01:00
parent 037a69d09e
commit e6e15bf66c
11 changed files with 77 additions and 77 deletions

View File

@ -42,11 +42,11 @@ class GolemResource(models.Model):
'order to sell reservations (work in '
'progress)')
avaibility_start = fields.Date(required=True, string='Availibility start date')
avaibility_stop = fields.Date(required=True, string='Availibility stop date')
availibility_24_7 = fields.Boolean(string='24/7 availibility')
availability_start = fields.Date(required=True, string='availability start date')
availability_stop = fields.Date(required=True, string='availability stop date')
availability_24_7 = fields.Boolean(string='24/7 availability')
timetable_ids = fields.One2many('golem.resource.timetable', 'resource_id',
string='Availibility timetable')
string='availability timetable')
reservation_ids = fields.One2many('golem.resource.reservation', 'resource_id',
string='Reservations')
reservation_count = fields.Integer(compute='_compute_reservation_count')
@ -86,10 +86,10 @@ class GolemResource(models.Model):
for resource in self:
resource.active = not resource.active
@api.constrains('avaibility_start', 'avaibility_stop')
@api.constrains('availability_start', 'availability_stop')
def _check_date_consistency(self):
""" Checks date consistency """
for resource in self:
if resource.avaibility_stop <= resource.avaibility_start:
raise ValidationError(_('End availibility should be after than '
'start availibility'))
if resource.availability_stop <= resource.availability_start:
raise ValidationError(_('End availability should be after than '
'start availability'))

View File

@ -45,9 +45,9 @@ class GolemResourceReservation(models.Model):
string='Resource', readonly=True,
track_visibility='onchange',
states={'draft': [('readonly', False)]})
resource_avaibility_start = fields.Date(related='resource_id.avaibility_start')
resource_avaibility_stop = fields.Date(related='resource_id.avaibility_stop')
resource_avaibility_24_7 = fields.Boolean(related='resource_id.availibility_24_7')
resource_availability_start = fields.Date(related='resource_id.availability_start')
resource_availability_stop = fields.Date(related='resource_id.availability_stop')
resource_availability_24_7 = fields.Boolean(related='resource_id.availability_24_7')
resource_timetable_ids = fields.One2many(related='resource_id.timetable_ids')
note = fields.Text(help='Notes, optional subject for the reservation, reason')
@ -153,16 +153,16 @@ class GolemResourceReservation(models.Model):
""" Check date coherence on reservation confirmation """
for reservation in self:
if reservation.state == 'confirmed':
# Check is reservation is not taking place out of the resource avaibility period
if reservation.date_start < reservation.resource_id.avaibility_start or \
reservation.date_stop > reservation.resource_id.avaibility_stop:
# Check is reservation is not taking place out of the resource availability period
if reservation.date_start < reservation.resource_id.availability_start or \
reservation.date_stop > reservation.resource_id.availability_stop:
verr = _('Not allowed, the resource is not available in '
'this period, please choose another périod before '
'confirming')
raise ValidationError(verr)
#check if the resource hasn't a total availibility
if not reservation.resource_id.availibility_24_7:
# Check if reservation is not taking place out the avaibility timetables
#check if the resource hasn't a total availability
if not reservation.resource_id.availability_24_7:
# Check if reservation is not taking place out the availability timetables
date_start = fields.Datetime.from_string(reservation.date_start)
date_stop = fields.Datetime.from_string(reservation.date_stop)
reservation_period = [date_start + timedelta(days=x) for x in range(
@ -170,12 +170,12 @@ class GolemResourceReservation(models.Model):
for reservation_day in reservation_period:
is_day_allowed = False
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 availability
#date = fields.Datetime.from_string(reservation_day)
if int(timetable.weekday) == reservation_day.weekday():
is_day_allowed = True
#only check if the day hasn't a 24 availibility
if not timetable.availibility_24:
#only check if the day hasn't a 24 availability
if not timetable.availability_24:
reservation_day_date = reservation_day.date()
day_start = date_start.date()
day_stop = date_stop.date()
@ -192,7 +192,7 @@ class GolemResourceReservation(models.Model):
else:
#if the day is not a start nor stop it
#should be covered on all day
#strange, as availibility_24 is not True
#strange, as availability_24 is not True
hour_start = 0.0
hour_stop = 23.98

View File

@ -39,13 +39,13 @@ class GolemTimetable(models.Model):
('6', _('Sunday'))], required=True)
time_start = fields.Float(string='Start')
time_stop = fields.Float(string='Stop')
availibility_24 = fields.Boolean(string="All day")
availability_24 = fields.Boolean(string="All day")
@api.onchange('availibility_24')
def onchange_availibility_24(self):
""" fill time_start et time_stop if availibility_24 is True """
@api.onchange('availability_24')
def onchange_availability_24(self):
""" fill time_start et time_stop if availability_24 is True """
for line in self:
if line.availibility_24:
if line.availability_24:
line.update({'time_start': 0.0, 'time_stop': 23.98})
@api.onchange('time_start')
@ -55,11 +55,11 @@ class GolemTimetable(models.Model):
if line.time_start and not line.time_stop:
line.time_stop = line.time_start + 1
@api.constrains('availibility_24')
def check_avaibility24(self):
""" Checks hour consistency against avaibility 24 """
@api.constrains('availability_24')
def check_availability24(self):
""" Checks hour consistency against availability 24 """
for line in self:
if line.availibility_24:
if line.availability_24:
line.write({'time_start': 0.0, 'time_stop': 23.98})
@api.constrains('time_start', 'time_stop')
@ -71,7 +71,7 @@ class GolemTimetable(models.Model):
@api.constrains('time_start', 'time_stop')
def _check_time_all_day(self):
""" Checks time all day availibility """
""" Checks time all day availability """
for timetable in self:
if timetable.time_stop > 23.98 and timetable.time_start == 0:
timetable.write({'availibility_24': True})
timetable.write({'availability_24': True})

View File

@ -30,8 +30,8 @@ class TestGolemResource(TransactionCase):
super(TestGolemResource, self).setUp(*args, **kwargs)
self.data = {
'name': 'Resource',
'avaibility_start': '2018-01-01',
'avaibility_stop': '2020-01-01'
'availability_start': '2018-01-01',
'availability_stop': '2020-01-01'
}
self.resource_obj = self.env['golem.resource']
@ -40,8 +40,8 @@ class TestGolemResource(TransactionCase):
resource = self.resource_obj.create(self.data)
self.assertTrue(resource.active)
self.assertFalse(resource.validation_required)
self.assertEqual(resource.avaibility_start, '2018-01-01')
self.assertEqual(resource.avaibility_stop, '2020-01-01')
self.assertEqual(resource.availability_start, '2018-01-01')
self.assertEqual(resource.availability_stop, '2020-01-01')
self.assertFalse(resource.supervisor_id)
self.assertFalse(resource.product_tmpl_id)
self.assertFalse(resource.timetable_ids)
@ -58,12 +58,12 @@ class TestGolemResource(TransactionCase):
def test_resource_dates(self):
""" Test resource dates : stop can not be after start """
self.data.update({'avaibility_stop': '2017-01-01'})
self.data.update({'availability_stop': '2017-01-01'})
with self.assertRaises(ValidationError):
self.resource_obj.create(self.data)
def test_resource_dates_equal(self):
""" Test resource dates : stop can not be equal to start """
self.data.update({'avaibility_stop': self.data['avaibility_start']})
self.data.update({'availability_stop': self.data['availability_start']})
with self.assertRaises(ValidationError):
self.resource_obj.create(self.data)

View File

@ -32,13 +32,13 @@ class TestGolemResourceReservation(TransactionCase):
super(TestGolemResourceReservation, self).setUp(*args, **kwargs)
self.resource = self.env['golem.resource'].create({
'name': 'Resource',
'avaibility_start': '2018-01-01',
'avaibility_stop': '2020-01-01'
'availability_start': '2018-01-01',
'availability_stop': '2020-01-01'
})
self.resource_val = self.env['golem.resource'].create({
'name': 'Resource to validate',
'avaibility_start': '2018-01-01',
'avaibility_stop': '2020-01-01',
'availability_start': '2018-01-01',
'availability_stop': '2020-01-01',
'validation_required': True
})
@ -47,11 +47,11 @@ class TestGolemResourceReservation(TransactionCase):
timetable_data = {'resource_id': self.resource.id, 'weekday': '0',
'time_start': 8.0, 'time_stop': 12.0}
timetable_data2 = {'resource_id': self.resource.id, 'weekday': '1',
'availibility_24': True}
'availability_24': True}
timetable_data3 = {'resource_id': self.resource.id, 'weekday': '2',
'time_start': 7.0, 'time_stop': 23.98}
timetable_data4 = {'resource_id': self.resource.id, 'weekday': '3',
'availibility_24': True}
'availability_24': True}
self.timetable_obj.create(timetable_data)
self.timetable_obj.create(timetable_data2)
@ -114,11 +114,11 @@ class TestGolemResourceReservation(TransactionCase):
reservation.state_confirm() # Here the reservation is OK, pass the checks
self.assertEqual(reservation.state, 'validated')
def test_avaibility_24_7(self):
""" Test reservation with avaibility 24/7 """
self.resource.availibility_24_7 = True
def test_availability_24_7(self):
""" Test reservation with availability 24/7 """
self.resource.availability_24_7 = True
self.resource.timetable_ids.unlink()
self.assertTrue(self.resource.availibility_24_7)
self.assertTrue(self.resource.availability_24_7)
reservation = self.res_obj.create(self.data)
reservation.state_confirm()
self.assertEqual(reservation.state, 'validated')

View File

@ -31,8 +31,8 @@ class TestGolemResourceTimetable(TransactionCase):
self.resource = self.env['golem.resource'].create({
'name': 'Resource',
'validation_required': False,
'avaibility_start': '2018-01-01',
'avaibility_stop': '2020-01-01'
'availability_start': '2018-01-01',
'availability_stop': '2020-01-01'
})
self.timetable_obj = self.env['golem.resource.timetable']
self.data = {'resource_id': self.resource.id,
@ -46,7 +46,7 @@ class TestGolemResourceTimetable(TransactionCase):
self.assertEqual(timetable.resource_id, self.resource)
self.assertEqual(timetable.time_start, 8.0)
self.assertEqual(timetable.time_stop, 10.0)
self.assertFalse(timetable.availibility_24)
self.assertFalse(timetable.availability_24)
self.assertEqual(timetable, self.resource.timetable_ids[0])
def test_timetable_times(self):

View File

@ -62,11 +62,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<group name="resource" string="Resource">
<field name="id" invisible="1" />
<field name="resource_id" options="{'no_create': True}" />
<field name="resource_avaibility_24_7" readonly="1" />
<field name="resource_avaibility_start" readonly="1" />
<field name="resource_avaibility_stop" readonly="1" />
<field name="resource_availability_24_7" readonly="1" />
<field name="resource_availability_start" readonly="1" />
<field name="resource_availability_stop" readonly="1" />
<field name="resource_timetable_ids" readonly="1"
attrs="{'invisible': [('resource_avaibility_24_7', '=', True)]}" />
attrs="{'invisible': [('resource_availability_24_7', '=', True)]}" />
</group>
<group name="reservation" string="Reservation">
<group>

View File

@ -26,7 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<tree editable="bottom">
<field name="resource_id" invisible="1" />
<field name="weekday" />
<field name="availibility_24"/>
<field name="availability_24"/>
<field name="time_start" string="Start hour" widget="float_time"
required="1" />
<field name="time_stop" string="Stop hour" widget="float_time"

View File

@ -29,8 +29,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="type_id" />
<field name="supervisor_id" />
<field name="product_tmpl_id" />
<field name="avaibility_start" />
<field name="avaibility_stop" />
<field name="availability_start" />
<field name="availability_stop" />
<field name="validation_required" />
</tree>
</field>
@ -68,19 +68,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="supervisor_id" />
</group>
</group>
<group string="Availibility configuration">
<group string="availability configuration">
<group colspan="2">
<field name="id" invisible="1"/>
<field name="availibility_24_7"/>
<field name="avaibility_start" />
<field name="avaibility_stop" />
<field name="availability_24_7"/>
<field name="availability_start" />
<field name="availability_stop" />
</group>
<p attrs="{'invisible': ['|',
('id', '!=', False),
('availibility_24_7', '=', True)]}">
Please save the resource before fixing the timetable availibility"
('availability_24_7', '=', True)]}">
Please save the resource before fixing the timetable availability"
</p>
<group colspan="2" attrs="{'invisible': [('availibility_24_7', '=', True)]}">
<group colspan="2" attrs="{'invisible': [('availability_24_7', '=', True)]}">
<field name="timetable_ids"
context="{'default_resource_id': active_id}"
attrs="{'readonly': [('id', '=', False)]}" />

View File

@ -32,16 +32,16 @@ class TestGolemResourcePack(TransactionCase):
self.resource = self.env['golem.resource'].create({
'name': 'Resource',
'avaibility_start': '2018-01-01',
'avaibility_stop': '2020-01-01',
'availibility_24_7': True
'availability_start': '2018-01-01',
'availability_stop': '2020-01-01',
'availability_24_7': True
})
self.resource_val = self.env['golem.resource'].create({
'name': 'Resource to validate',
'avaibility_start': '2018-01-01',
'avaibility_stop': '2020-01-01',
'availability_start': '2018-01-01',
'availability_stop': '2020-01-01',
'validation_required': True,
'availibility_24_7': True
'availability_24_7': True
})
self.partner = self.env['res.partner'].create({'firstname': 'John',

View File

@ -44,15 +44,15 @@ class TestGolemResourcePack(TransactionCase):
self.resource_1 = self.env['golem.resource'].create({
'name': 'Resource1',
'product_tmpl_id': self.product.id,
'avaibility_start': '2018-01-01',
'avaibility_stop': '2020-01-01',
'availibility_24_7': True
'availability_start': '2018-01-01',
'availability_stop': '2020-01-01',
'availability_24_7': True
})
self.resource_2 = self.env['golem.resource'].create({
'name': 'Resource2',
'avaibility_start': '2018-01-01',
'avaibility_stop': '2020-01-01',
'availibility_24_7': True
'availability_start': '2018-01-01',
'availability_stop': '2020-01-01',
'availability_24_7': True
})
#set partners