diff --git a/pms/models/pms_board_service_room_type.py b/pms/models/pms_board_service_room_type.py index 95dcc6900d..1c50c916d2 100644 --- a/pms/models/pms_board_service_room_type.py +++ b/pms/models/pms_board_service_room_type.py @@ -60,6 +60,11 @@ class PmsBoardServiceRoomType(models.Model): string="Apply by Default", 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") def _compute_board_amount(self): @@ -86,11 +91,11 @@ def constrains_duplicated_board_default(self): "by_default" ) ) - # TODO Check properties (with different propertys is allowed) if any( default_boards.filtered( - lambda l: l.id != record.id - and l.pms_property_id == record.pms_property_id + lambda board: board.id != record.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""")) diff --git a/pms/models/pms_reservation.py b/pms/models/pms_reservation.py index de77cd94dc..c36e06d39d 100644 --- a/pms/models/pms_reservation.py +++ b/pms/models/pms_reservation.py @@ -770,13 +770,25 @@ def _compute_check_adults(self): def _compute_board_service_room_id(self): for reservation in self: 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), ("by_default", "=", True), ("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 ( not reservation.board_service_room_id or not reservation.board_service_room_id.pms_room_type_id diff --git a/pms/views/pms_room_type_views.xml b/pms/views/pms_room_type_views.xml index 425f91f5c9..a6dfb6283a 100644 --- a/pms/views/pms_room_type_views.xml +++ b/pms/views/pms_room_type_views.xml @@ -75,6 +75,10 @@ icon="fa-2x fa-bars" name="open_board_lines_form" /> + diff --git a/pms/wizards/wizard_folio_changes.py b/pms/wizards/wizard_folio_changes.py index 5adbfc0798..f41583549a 100644 --- a/pms/wizards/wizard_folio_changes.py +++ b/pms/wizards/wizard_folio_changes.py @@ -390,6 +390,10 @@ def _add_board_service(self, reservations, new_board_service_id): reservation.folio_id.pms_property_id.id == x.pms_property_id.ids ) + and ( + not x.pricelist_ids + or reservation.pricelist_id.id in x.pricelist_ids.ids + ) ) )