mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] compute priority from folio
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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",
|
||||
# )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user