mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[FIX] Room capacity can't be less than one
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user