mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
@@ -188,13 +188,13 @@ class PmsReservationLine(models.Model):
|
|||||||
|
|
||||||
# we get the rooms available for the entire stay
|
# we get the rooms available for the entire stay
|
||||||
rooms_available = self.env["pms.availability.plan"].rooms_available(
|
rooms_available = self.env["pms.availability.plan"].rooms_available(
|
||||||
checkin=line.reservation_id.checkin,
|
checkin=reservation.checkin,
|
||||||
checkout=line.reservation_id.checkout,
|
checkout=reservation.checkout,
|
||||||
room_type_id=reservation.room_type_id.id
|
room_type_id=reservation.room_type_id.id
|
||||||
if not free_room_select
|
if not free_room_select
|
||||||
else False,
|
else False,
|
||||||
current_lines=line.reservation_id.reservation_line_ids.ids,
|
current_lines=reservation.reservation_line_ids.ids,
|
||||||
pricelist_id=line.reservation_id.pricelist_id.id,
|
pricelist_id=reservation.pricelist_id.id,
|
||||||
pms_property_id=line.pms_property_id.id,
|
pms_property_id=line.pms_property_id.id,
|
||||||
)
|
)
|
||||||
# if there is availability for the entire stay
|
# if there is availability for the entire stay
|
||||||
@@ -209,14 +209,18 @@ class PmsReservationLine(models.Model):
|
|||||||
|
|
||||||
# if the preferred room is NOT available
|
# if the preferred room is NOT available
|
||||||
else:
|
else:
|
||||||
raise ValidationError(
|
if self.env.context.get("force_overbooking"):
|
||||||
_("%s: No room available in %s <-> %s.")
|
reservation.overbooking = True
|
||||||
% (
|
line.room_id = reservation.preferred_room_id
|
||||||
reservation.preferred_room_id.name,
|
else:
|
||||||
line.reservation_id.checkin,
|
raise ValidationError(
|
||||||
line.reservation_id.checkout,
|
_("%s: No room available in %s <-> %s.")
|
||||||
|
% (
|
||||||
|
reservation.preferred_room_id.name,
|
||||||
|
reservation.checkin,
|
||||||
|
reservation.checkout,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
# otherwise we assign the first of those
|
# otherwise we assign the first of those
|
||||||
# available for the entire stay
|
# available for the entire stay
|
||||||
@@ -224,17 +228,21 @@ class PmsReservationLine(models.Model):
|
|||||||
line.room_id = rooms_available[0]
|
line.room_id = rooms_available[0]
|
||||||
# check that the reservation cannot be allocated even by dividing it
|
# check that the reservation cannot be allocated even by dividing it
|
||||||
elif not self.env["pms.availability.plan"].splitted_availability(
|
elif not self.env["pms.availability.plan"].splitted_availability(
|
||||||
checkin=line.reservation_id.checkin,
|
checkin=reservation.checkin,
|
||||||
checkout=line.reservation_id.checkout,
|
checkout=reservation.checkout,
|
||||||
room_type_id=line.reservation_id.room_type_id.id,
|
room_type_id=reservation.room_type_id.id,
|
||||||
current_lines=line._origin.reservation_id.reservation_line_ids.ids,
|
current_lines=line._origin.reservation_id.reservation_line_ids.ids,
|
||||||
pricelist=line.reservation_id.pricelist_id,
|
pricelist=reservation.pricelist_id,
|
||||||
pms_property_id=line.pms_property_id.id,
|
pms_property_id=line.pms_property_id.id,
|
||||||
):
|
):
|
||||||
raise ValidationError(
|
if self.env.context.get("force_overbooking"):
|
||||||
_("%s: No room type available")
|
reservation.overbooking = True
|
||||||
% (line.reservation_id.room_type_id.name)
|
line.room_id = reservation.room_type_id.room_ids[0]
|
||||||
)
|
else:
|
||||||
|
raise ValidationError(
|
||||||
|
_("%s: No room type available")
|
||||||
|
% (reservation.room_type_id.name)
|
||||||
|
)
|
||||||
|
|
||||||
# the reservation can be allocated into several rooms
|
# the reservation can be allocated into several rooms
|
||||||
else:
|
else:
|
||||||
@@ -350,7 +358,7 @@ class PmsReservationLine(models.Model):
|
|||||||
lang=partner.lang,
|
lang=partner.lang,
|
||||||
partner=partner.id,
|
partner=partner.id,
|
||||||
quantity=1,
|
quantity=1,
|
||||||
date=line.reservation_id.date_order,
|
date=reservation.date_order,
|
||||||
consumption_date=line.date,
|
consumption_date=line.date,
|
||||||
pricelist=reservation.pricelist_id.id,
|
pricelist=reservation.pricelist_id.id,
|
||||||
uom=product.uom_id.id,
|
uom=product.uom_id.id,
|
||||||
@@ -359,8 +367,8 @@ class PmsReservationLine(models.Model):
|
|||||||
line.price = self.env["account.tax"]._fix_tax_included_price_company(
|
line.price = self.env["account.tax"]._fix_tax_included_price_company(
|
||||||
line._get_display_price(product),
|
line._get_display_price(product),
|
||||||
product.taxes_id,
|
product.taxes_id,
|
||||||
line.reservation_id.tax_ids,
|
reservation.tax_ids,
|
||||||
line.reservation_id.company_id,
|
reservation.company_id,
|
||||||
)
|
)
|
||||||
# TODO: Out of service 0 amount
|
# TODO: Out of service 0 amount
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user