diff --git a/pms/models/pms_folio.py b/pms/models/pms_folio.py index 62eddc70b..4240fb818 100644 --- a/pms/models/pms_folio.py +++ b/pms/models/pms_folio.py @@ -404,10 +404,11 @@ class PmsFolio(models.Model): reservations_pending_count = fields.Integer( compute="_compute_reservations_pending_arrival" ) - max_reservation_prior = fields.Integer( + max_reservation_priority = fields.Integer( string="Max reservation priority on the entire folio", help="Max reservation priority on the entire folio", - compute="_compute_max_reservation_prior", + compute="_compute_max_reservation_priority", + store=True, ) invoice_status = fields.Selection( string="Invoice Status", @@ -926,10 +927,11 @@ class PmsFolio(models.Model): } record.update(vals) - def _compute_max_reservation_prior(self): + @api.depends("reservation_ids", "reservation_ids.priority") + def _compute_max_reservation_priority(self): for record in self: reservation_priors = record.reservation_ids.mapped("priority") - record.max_reservation_prior = max(reservation_priors) + record.max_reservation_priority = max(reservation_priors) def _compute_checkin_partner_count(self): for record in self: diff --git a/pms/models/product_pricelist.py b/pms/models/product_pricelist.py index db3811c9b..0b1873df2 100644 --- a/pms/models/product_pricelist.py +++ b/pms/models/product_pricelist.py @@ -125,7 +125,6 @@ class ProductPricelist(models.Model): self._context["consumption_date"], ), ) - item_ids = [x[0] for x in self.env.cr.fetchall()] items = self.env["product.pricelist.item"].browse(item_ids) if board_service: @@ -149,6 +148,8 @@ class ProductPricelist(models.Model): if record.pricelist_type == "daily" and ( item.compute_price != "fixed" or len(record.pms_property_ids) != 1 + or not item.date_end_consumption + or not item.date_start_consumption or item.date_end_consumption != item.date_start_consumption ): raise ValidationError( diff --git a/pms/tests/test_pms_folio.py b/pms/tests/test_pms_folio.py index 2fe41c34e..6d058fb83 100644 --- a/pms/tests/test_pms_folio.py +++ b/pms/tests/test_pms_folio.py @@ -257,7 +257,7 @@ class TestPmsFolio(TestPms): # self.assertEqual( # reservation1.priority, - # reservation1.folio_id.max_reservation_prior, + # reservation1.folio_id.max_reservation_priority, # "The max. reservation priority on the whole folio is incorrect", # )