[FIX] pms: fix _check_adults @ pms_reservation

This commit is contained in:
miguelpadin
2021-06-29 23:45:14 +02:00
parent 63340f87dc
commit 653ebec786

View File

@@ -1426,13 +1426,13 @@ class PmsReservation(models.Model):
@api.constrains("adults") @api.constrains("adults")
def _check_adults(self): def _check_adults(self):
for record in self: for record in self:
extra_bed = record.service_ids.filtered( for line in record.reservation_line_ids:
lambda r: r.product_id.is_extra_bed is True extra_beds = record.service_ids.service_line_ids.filtered(
) lambda x: x.date == line.date and x.product_id.is_extra_bed is True
for room in record.reservation_line_ids.room_id: )
if record.adults + record.children_occupying > room.get_capacity( if (
sum(extra_bed.mapped("product_qty")) record.adults + record.children_occupying
): ) > line.room_id.get_capacity(len(extra_beds)):
raise ValidationError( raise ValidationError(
_( _(
"Persons can't be higher than room capacity (%s)", "Persons can't be higher than room capacity (%s)",