Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

14.0 apply board service by pricelist filter #311

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions pms/models/pms_board_service_room_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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"""))
Expand Down
14 changes: 13 additions & 1 deletion pms/models/pms_reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions pms/views/pms_room_type_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
icon="fa-2x fa-bars"
name="open_board_lines_form"
/>
<field
name="pricelist_ids"
widget="many2many_tags"
/>
</tree>
</field>
</page>
Expand Down
4 changes: 4 additions & 0 deletions pms/wizards/wizard_folio_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
)

Expand Down
Loading