[FIX] Room capacity can't be less than one

This commit is contained in:
Pablo Quesada Barriuso
2018-07-27 17:42:18 +02:00
parent 6915dd9f82
commit 5b12446bc5
2 changed files with 8 additions and 6 deletions

View File

@@ -1165,11 +1165,8 @@ class HotelReservation(models.Model):
return {'total_price': total_price, 'commands': cmds}
@api.constrains('adults')
def check_adults(self):
if self.adults == 0 and self.room_id:
# room = self.env['hotel.room'].search([
# ('product_id', '=', self.product_id.id)
# ], limit=1)
def _check_adults(self):
if self.adults == 0 and self.room_id and self.room_id > 0:
self.adults = self.room_id.capacity
@api.multi

View File

@@ -3,7 +3,7 @@
# Copyright 2017 Dario Lodeiros
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
class HotelRoom(models.Model):
""" The rooms for lodging can be for sleeping, usually called rooms, and also
@@ -45,3 +45,8 @@ class HotelRoom(models.Model):
help="A description of the Product that you want to communicate to "
" your customers. This description will be copied to every Sales "
" Order, Delivery Order and Customer Invoice/Credit Note")
@api.constrains('capacity')
def _check_capacity(self):
if self.capacity < 1:
raise ValidationError(_("Room capacity can't be less than one"))