diff --git a/pos_restaurant_table_booking/models/restaurant_booking.py b/pos_restaurant_table_booking/models/restaurant_booking.py index eb2de61..4b4efa5 100644 --- a/pos_restaurant_table_booking/models/restaurant_booking.py +++ b/pos_restaurant_table_booking/models/restaurant_booking.py @@ -54,6 +54,12 @@ class RestaurantBooking(models.Model): table_booking_ids = fields.One2many(comodel_name="restaurant.table_booking", inverse_name="booking_id", string="Tables bookings", readonly=True) + _sql_constraints = [ + ('start_time_check', 'CHECK(time_start >= 0 AND time_start <= 24)', "The start time must be between 0 and 24.") + ('stop_time_check', 'CHECK(time_stop >= 0 AND time_stop <= 24)', "The stop time must be between 0 and 24.") + ('times_order_check', 'CHECK(time_start < time_stop)', "The start time must be lower than the stop time.") + ] + @api.depends('time_start', 'duration') def _get_time_stop(self): for booking in self: @@ -114,6 +120,8 @@ class RestaurantBooking(models.Model): else: booking.available_table_ids = [(5, 0, 0)] + # CRUD + @api.model_create_multi def create(self, vals_list): for vals in vals_list: diff --git a/pos_restaurant_table_booking/views/res_config_settings.xml b/pos_restaurant_table_booking/views/res_config_settings.xml index 6f997cf..c72138d 100644 --- a/pos_restaurant_table_booking/views/res_config_settings.xml +++ b/pos_restaurant_table_booking/views/res_config_settings.xml @@ -13,18 +13,15 @@