mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD]pms: add filtering by pricelist in board service room type
This commit is contained in:
@@ -60,6 +60,11 @@ class PmsBoardServiceRoomType(models.Model):
|
|||||||
string="Apply by Default",
|
string="Apply by Default",
|
||||||
help="Indicates if this board service is applied by default in the room type",
|
help="Indicates if this board service is applied by default in the room type",
|
||||||
)
|
)
|
||||||
|
pricelist_ids = fields.Many2many(
|
||||||
|
string="Pricelists",
|
||||||
|
help="Pricelists where this Board Service is available",
|
||||||
|
comodel_name="product.pricelist",
|
||||||
|
)
|
||||||
|
|
||||||
@api.depends("board_service_line_ids.amount")
|
@api.depends("board_service_line_ids.amount")
|
||||||
def _compute_board_amount(self):
|
def _compute_board_amount(self):
|
||||||
@@ -86,11 +91,11 @@ class PmsBoardServiceRoomType(models.Model):
|
|||||||
"by_default"
|
"by_default"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# TODO Check properties (with different propertys is allowed)
|
|
||||||
if any(
|
if any(
|
||||||
default_boards.filtered(
|
default_boards.filtered(
|
||||||
lambda l: l.id != record.id
|
lambda board: board.id != record.id
|
||||||
and l.pms_property_id == record.pms_property_id
|
and board.pms_property_id == record.pms_property_id
|
||||||
|
and board.pricelist_ids == record.pricelist_ids
|
||||||
)
|
)
|
||||||
):
|
):
|
||||||
raise UserError(_("""Only can set one default board service"""))
|
raise UserError(_("""Only can set one default board service"""))
|
||||||
|
|||||||
@@ -770,13 +770,25 @@ class PmsReservation(models.Model):
|
|||||||
def _compute_board_service_room_id(self):
|
def _compute_board_service_room_id(self):
|
||||||
for reservation in self:
|
for reservation in self:
|
||||||
if reservation.pricelist_id and reservation.room_type_id:
|
if reservation.pricelist_id and reservation.room_type_id:
|
||||||
board_service_default = self.env["pms.board.service.room.type"].search(
|
board_services_candidates = self.env[
|
||||||
|
"pms.board.service.room.type"
|
||||||
|
].search(
|
||||||
[
|
[
|
||||||
("pms_room_type_id", "=", reservation.room_type_id.id),
|
("pms_room_type_id", "=", reservation.room_type_id.id),
|
||||||
("by_default", "=", True),
|
("by_default", "=", True),
|
||||||
("pms_property_id", "=", reservation.pms_property_id.id),
|
("pms_property_id", "=", reservation.pms_property_id.id),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
board_service_default = (
|
||||||
|
board_services_candidates.filtered(
|
||||||
|
lambda service: reservation.pricelist_id
|
||||||
|
in service.pricelist_ids
|
||||||
|
)
|
||||||
|
or board_services_candidates.filtered(
|
||||||
|
lambda service: not service.pricelist_ids
|
||||||
|
)
|
||||||
|
or False
|
||||||
|
)
|
||||||
if (
|
if (
|
||||||
not reservation.board_service_room_id
|
not reservation.board_service_room_id
|
||||||
or not reservation.board_service_room_id.pms_room_type_id
|
or not reservation.board_service_room_id.pms_room_type_id
|
||||||
|
|||||||
@@ -75,6 +75,10 @@
|
|||||||
icon="fa-2x fa-bars"
|
icon="fa-2x fa-bars"
|
||||||
name="open_board_lines_form"
|
name="open_board_lines_form"
|
||||||
/>
|
/>
|
||||||
|
<field
|
||||||
|
name="pricelist_ids"
|
||||||
|
widget="many2many_tags"
|
||||||
|
/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
|
|||||||
@@ -390,6 +390,10 @@ class WizardFolioChanges(models.TransientModel):
|
|||||||
reservation.folio_id.pms_property_id.id
|
reservation.folio_id.pms_property_id.id
|
||||||
== x.pms_property_id.ids
|
== x.pms_property_id.ids
|
||||||
)
|
)
|
||||||
|
and (
|
||||||
|
not x.pricelist_ids
|
||||||
|
or reservation.pricelist_id.id in x.pricelist_ids.ids
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user