From 3a207d3a2492fb85681da638e1895de5112e9c1f Mon Sep 17 00:00:00 2001 From: Pablo Date: Fri, 13 Sep 2019 17:47:39 +0200 Subject: [PATCH] [UPD] code unique constraint by hotel --- hotel/models/hotel_room_type.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hotel/models/hotel_room_type.py b/hotel/models/hotel_room_type.py index 7805a477d..fe1c3caa8 100644 --- a/hotel/models/hotel_room_type.py +++ b/hotel/models/hotel_room_type.py @@ -53,18 +53,15 @@ class HotelRoomType(models.Model): # total number of rooms in this type total_rooms_count = fields.Integer(compute='_compute_total_rooms', store=True) - _sql_constraints = [('code_unique', 'unique(code_type)', - 'Room Type Code must be unique!')] + _sql_constraints = [ + ('code_hotel_unique', 'unique(code_type, hotel_id)', 'Room Type Code must be unique by Hotel!'), + ] @api.depends('room_ids', 'room_ids.active') def _compute_total_rooms(self): for record in self: record.total_rooms_count = len(record.room_ids) - def _check_duplicated_rooms(self): - # FIXME Using a Many2one relationship duplicated should not been possible - pass - @api.multi def get_capacity(self): """