[FIX]pms_api_rest: fix children board get price

This commit is contained in:
Darío Lodeiros
2024-07-27 11:16:03 +02:00
parent 869137b051
commit 2b452ee325
2 changed files with 29 additions and 18 deletions

View File

@@ -327,6 +327,7 @@ class PmsService(models.Model):
"reservation_id.reservation_line_ids",
"product_id",
"reservation_id.adults",
"reservation_id.children",
"product_qty",
)
# flake8:noqa=C901
@@ -572,7 +573,6 @@ class PmsService(models.Model):
if origin:
partner = origin.partner_id
pricelist = origin.pricelist_id
board_room_type = False
product_context = dict(
self.env.context,
lang=partner.lang,
@@ -580,7 +580,6 @@ class PmsService(models.Model):
quantity=self.product_qty,
date=folio.date_order if folio else fields.Date.today(),
pricelist=pricelist.id,
board_service=board_room_type.id if board_room_type else False,
uom=self.product_id.uom_id.id,
fiscal_position=False,
property=origin.pms_property_id.id,
@@ -591,6 +590,10 @@ class PmsService(models.Model):
product_context[
"board_service"
] = reservation.board_service_room_id.id
if reservation and self.board_service_line_id:
product_context[
"board_service_line_id"
] = self.board_service_line_id.id
product = self.product_id.with_context(product_context)
return self.env["account.tax"]._fix_tax_included_price_company(
self.env["product.product"]._pms_get_display_price(

View File

@@ -18,10 +18,11 @@ class ProductProduct(models.Model):
compute="_compute_room_type_id",
)
@api.depends_context("consumption_date")
@api.depends_context("consumption_date", "board_service_line_id")
def _compute_product_price(self):
super(ProductProduct, self)._compute_product_price()
@api.depends_context("consumption_date", "board_service_line_id")
def _compute_board_price(self):
pms_property_id = (
self.env.context.get("property")
@@ -29,22 +30,29 @@ class ProductProduct(models.Model):
)
for record in self:
if self._context.get("board_service"):
record.board_price = (
self.env["pms.board.service.room.type.line"]
.search(
[
(
"pms_board_service_room_type_id",
"=",
self._context.get("board_service"),
),
("product_id", "=", record.id),
("pms_property_id", "=", pms_property_id),
],
limit=1,
if self._context.get("board_service_line_id"):
record.board_price = (
self.env["pms.board.service.room.type.line"]
.browse(self._context.get("board_service_line_id"))
.amount
)
else:
record.board_price = (
self.env["pms.board.service.room.type.line"]
.search(
[
(
"pms_board_service_room_type_id",
"=",
self._context.get("board_service"),
),
("product_id", "=", record.id),
("pms_property_id", "=", pms_property_id),
],
limit=1,
)
.amount
)
.amount
)
else:
record.board_price = False