From 72569ca05f09f08346542c9d1d301d2732abf06d Mon Sep 17 00:00:00 2001 From: Pablo Date: Mon, 9 Sep 2019 16:42:57 +0200 Subject: [PATCH] [WIP] refactoring default_ arrival and departure hours --- hotel/models/hotel_property.py | 9 +++++---- hotel/models/hotel_reservation.py | 4 ++-- hotel/views/hotel_property_views.xml | 4 ++-- hotel/views/hotel_reservation_views.xml | 4 ++-- hotel_calendar/models/inherited_hotel_reservation.py | 4 ++-- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/hotel/models/hotel_property.py b/hotel/models/hotel_property.py index cc9f47e9f..bc0331b05 100644 --- a/hotel/models/hotel_property.py +++ b/hotel/models/hotel_property.py @@ -32,17 +32,18 @@ class HotelProperty(models.Model): required=True) # TODO: refactoring 'res.config.settings', 'default_arrival_hour' by the current hotel.property.arrival_hour - arrival_hour = fields.Char('Arrival Hour (GMT)', - help="HH:mm Format", default="14:00") + default_arrival_hour = fields.Char('Arrival Hour (GMT)', + help="HH:mm Format", default="14:00") # TODO: refactoring 'res.config.settings', 'default_departure_hour' by the current hotel.property.departure_hour - departure_hour = fields.Char('Departure Hour (GMT)', - help="HH:mm Format", default="12:00") + default_departure_hour = fields.Char('Departure Hour (GMT)', + help="HH:mm Format", default="12:00") # TODO: refactoring 'res.config.settings', 'tz_hotel' by the current hotel.property.tz (inherited in res.partner) default_cancel_policy_days = fields.Integer('Cancellation Days') default_cancel_policy_percent = fields.Float('Percent to pay') + @api.constrains('default_arrival_hour', 'default_departure_hour') def _check_hours(self): r = re.compile('[0-2][0-9]:[0-5][0-9]') if not r.match(self.arrival_hour): diff --git a/hotel/models/hotel_reservation.py b/hotel/models/hotel_reservation.py index 6a512b90b..eacba2098 100644 --- a/hotel/models/hotel_reservation.py +++ b/hotel/models/hotel_reservation.py @@ -51,7 +51,7 @@ class HotelReservation(models.Model): def _get_default_arrival_hour(self): folio = False - default_arrival_hour = self.env.user.hotel_id.arrival_hour + default_arrival_hour = self.env.user.hotel_id.default_arrival_hour if 'folio_id' in self._context: folio = self.env['hotel.folio'].search([ ('id', '=', self._context['folio_id']) @@ -63,7 +63,7 @@ class HotelReservation(models.Model): def _get_default_departure_hour(self): folio = False - default_departure_hour = self.env.user.hotel_id.departure_hour + default_departure_hour = self.env.user.hotel_id.default_departure_hour if 'folio_id' in self._context: folio = self.env['hotel.folio'].search([ ('id', '=', self._context['folio_id']) diff --git a/hotel/views/hotel_property_views.xml b/hotel/views/hotel_property_views.xml index b7e368d50..7befee792 100644 --- a/hotel/views/hotel_property_views.xml +++ b/hotel/views/hotel_property_views.xml @@ -28,8 +28,8 @@ - - + + diff --git a/hotel/views/hotel_reservation_views.xml b/hotel/views/hotel_reservation_views.xml index 92702a332..b63fccc2b 100644 --- a/hotel/views/hotel_reservation_views.xml +++ b/hotel/views/hotel_reservation_views.xml @@ -196,8 +196,8 @@ attrs="{'invisible': [('reservation_type','in',('out'))]}"/> - - + +