mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms: improvement compute overbooking and boardservices
This commit is contained in:
@@ -1810,7 +1810,7 @@ class PmsFolio(models.Model):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def _message_post_after_hook(self, message, msg_vals):
|
def _message_post_after_hook(self, message, msg_vals):
|
||||||
res = super(PmsFolio, self).sudo()._message_post_after_hook(message, msg_vals)
|
res = super(PmsFolio, self)._message_post_after_hook(message, msg_vals)
|
||||||
for folio in self:
|
for folio in self:
|
||||||
for follower in folio.message_follower_ids:
|
for follower in folio.message_follower_ids:
|
||||||
follower.sudo().unlink()
|
follower.sudo().unlink()
|
||||||
|
|||||||
@@ -1011,14 +1011,14 @@ class PmsReservation(models.Model):
|
|||||||
if (reservation.adults and line.adults) or (
|
if (reservation.adults and line.adults) or (
|
||||||
reservation.children and line.children
|
reservation.children and line.children
|
||||||
):
|
):
|
||||||
res = {
|
data = {
|
||||||
"product_id": line.product_id.id,
|
"product_id": line.product_id.id,
|
||||||
"is_board_service": True,
|
"is_board_service": True,
|
||||||
"folio_id": reservation.folio_id.id,
|
"folio_id": reservation.folio_id.id,
|
||||||
"reservation_id": reservation.id,
|
"reservation_id": reservation.id,
|
||||||
"board_service_line_id": line.id,
|
"board_service_line_id": line.id,
|
||||||
}
|
}
|
||||||
board_services.append((0, False, res))
|
board_services.append((0, False, data))
|
||||||
reservation.service_ids -= old_board_lines
|
reservation.service_ids -= old_board_lines
|
||||||
reservation.service_ids = board_services
|
reservation.service_ids = board_services
|
||||||
elif old_board_lines:
|
elif old_board_lines:
|
||||||
@@ -2153,7 +2153,29 @@ class PmsReservation(models.Model):
|
|||||||
vals.get("reservation_line_ids")
|
vals.get("reservation_line_ids")
|
||||||
and any(
|
and any(
|
||||||
[
|
[
|
||||||
("date" in line[2] or "price" in line[2])
|
(
|
||||||
|
"date" in line[2]
|
||||||
|
and (
|
||||||
|
datetime.datetime.strptime(
|
||||||
|
line[2]["date"], "%Y-%m-%d"
|
||||||
|
).date()
|
||||||
|
!= self.env["pms.reservation.line"]
|
||||||
|
.browse(line[1])
|
||||||
|
.date
|
||||||
|
)
|
||||||
|
)
|
||||||
|
or (
|
||||||
|
"price" in line[2]
|
||||||
|
and (
|
||||||
|
round(line[2]["price"], 2)
|
||||||
|
!= round(
|
||||||
|
self.env["pms.reservation.line"]
|
||||||
|
.browse(line[1])
|
||||||
|
.price,
|
||||||
|
2,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
for line in vals.get("reservation_line_ids")
|
for line in vals.get("reservation_line_ids")
|
||||||
if line[0] == 1
|
if line[0] == 1
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -440,7 +440,10 @@ class PmsReservationLine(models.Model):
|
|||||||
).ids
|
).ids
|
||||||
if (
|
if (
|
||||||
record.occupies_availability
|
record.occupies_availability
|
||||||
and not self.env.context.get("avoid_availability_check", False)
|
and not (
|
||||||
|
self.env.context.get("avoid_availability_check", False)
|
||||||
|
or self.env.context.get("force_overbooking", False)
|
||||||
|
)
|
||||||
and record.room_id.id
|
and record.room_id.id
|
||||||
in avail.get_rooms_not_avail(
|
in avail.get_rooms_not_avail(
|
||||||
checkin=record.date,
|
checkin=record.date,
|
||||||
@@ -475,10 +478,10 @@ class PmsReservationLine(models.Model):
|
|||||||
discount = first_discount + cancel_discount
|
discount = first_discount + cancel_discount
|
||||||
line.price_day_total = line.price - discount
|
line.price_day_total = line.price - discount
|
||||||
|
|
||||||
@api.depends("room_id", "avail_id", "avail_id.real_avail", "occupies_availability")
|
@api.depends("room_id", "state", "is_reselling")
|
||||||
def _compute_overbooking(self):
|
def _compute_overbooking(self):
|
||||||
for record in self.filtered("room_id"):
|
for record in self.filtered("room_id"):
|
||||||
if record.occupies_availability:
|
if record.state != "cancel" and not record.is_reselling:
|
||||||
record_id = (
|
record_id = (
|
||||||
record.id
|
record.id
|
||||||
if isinstance(record, int)
|
if isinstance(record, int)
|
||||||
@@ -495,8 +498,8 @@ class PmsReservationLine(models.Model):
|
|||||||
]
|
]
|
||||||
):
|
):
|
||||||
record.overbooking = True
|
record.overbooking = True
|
||||||
else:
|
else:
|
||||||
record.overbooking = False
|
record.overbooking = False
|
||||||
|
|
||||||
@api.model_create_multi
|
@api.model_create_multi
|
||||||
def create(self, vals_list):
|
def create(self, vals_list):
|
||||||
|
|||||||
@@ -587,6 +587,10 @@
|
|||||||
widget="many2many_tags"
|
widget="many2many_tags"
|
||||||
optional="show"
|
optional="show"
|
||||||
/>
|
/>
|
||||||
|
<field
|
||||||
|
name="board_service_line_id"
|
||||||
|
invisible="1"
|
||||||
|
/>
|
||||||
<field name="price_subtotal" optional="hide" />
|
<field name="price_subtotal" optional="hide" />
|
||||||
<field name="price_tax" optional="hide" />
|
<field name="price_tax" optional="hide" />
|
||||||
<field name="discount" />
|
<field name="discount" />
|
||||||
|
|||||||
Reference in New Issue
Block a user