Skip to content

Commit

Permalink
[FIX] pms: tests corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankC013 committed May 8, 2024
1 parent 472c9c0 commit 31e8ddc
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 8 deletions.
9 changes: 8 additions & 1 deletion pms/models/pms_board_service_line.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2017 Dario Lodeiros
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError


class PmsBoardServiceLine(models.Model):
Expand Down Expand Up @@ -123,3 +124,9 @@ def write(self, vals):
}
)
return super(PmsBoardServiceLine, self).write(vals)

@api.constrains("adults", "children")
def _check_adults_children(self):
for record in self:
if not record.adults and not record.children:
raise ValidationError(_("Adults or Children must be checked"))
1 change: 0 additions & 1 deletion pms/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down
6 changes: 4 additions & 2 deletions pms/tests/test_pms_booking_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,14 +758,15 @@ def test_price_total_with_board_service(self):
self.board_service_test = self.env["pms.board.service"].create(
{
"name": "Test Board Service",
"default_code": "TPS",
"default_code": "TBS",
}
)
self.env["pms.board.service.line"].create(
{
"pms_board_service_id": self.board_service_test.id,
"product_id": self.product_test1.id,
"amount": 8,
"adults": True,
}
)
self.board_service_room_type = self.env["pms.board.service.room.type"].create(
Expand Down Expand Up @@ -844,14 +845,15 @@ def _test_board_service_discount(self):
self.board_service_test = self.env["pms.board.service"].create(
{
"name": "Test Board Service",
"default_code": "TPS",
"default_code": "TBS",
}
)
self.env["pms.board.service.line"].create(
{
"pms_board_service_id": self.board_service_test.id,
"product_id": self.product_test1.id,
"amount": 8,
"adults": True,
}
)
self.board_service_room_type = self.env["pms.board.service.room.type"].create(
Expand Down
5 changes: 5 additions & 0 deletions pms/tests/test_pms_folio_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ def test_price_invoice_board_service(self):
"product_id": self.product1.id,
"pms_board_service_id": self.board_service1.id,
"amount": 10,
"adults": True,
}
)

Expand Down Expand Up @@ -545,6 +546,7 @@ def test_qty_invoiced_board_service(self):
"product_id": self.product1.id,
"pms_board_service_id": self.board_service1.id,
"amount": 10,
"adults": True,
}
)

Expand Down Expand Up @@ -603,6 +605,7 @@ def test_qty_to_invoice_board_service(self):
"product_id": self.product1.id,
"pms_board_service_id": self.board_service1.id,
"amount": 10,
"adults": True,
}
)

Expand Down Expand Up @@ -759,6 +762,7 @@ def test_autoinvoice_paid_folio_overnights_partner_policy(self):
"product_id": self.product1.id,
"pms_board_service_id": self.board_service1.id,
"amount": 10,
"adults": True,
}
)

Expand Down Expand Up @@ -862,6 +866,7 @@ def test_not_autoinvoice_unpaid_cancel_folio_partner_policy(self):
"product_id": self.product1.id,
"pms_board_service_id": self.board_service1.id,
"amount": 10,
"adults": True,
}
)

Expand Down
1 change: 1 addition & 0 deletions pms/tests/test_pms_folio_sale_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def setUpClass(cls):
"pms_board_service_id": cls.board_service_test.id,
"product_id": cls.product_test1.id,
"amount": 8,
"adults": True,
}
)
cls.board_service_room_type = cls.env["pms.board.service.room.type"].create(
Expand Down
3 changes: 3 additions & 0 deletions pms/tests/test_pms_multiproperty.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ def test_pms_bsl_product_property_integrity(self):
{
"product_id": product1.id,
"pms_board_service_id": board_service1.id,
"adults": True,
}
)

Expand Down Expand Up @@ -315,6 +316,7 @@ def test_pms_bsl_board_service_property_integrity(self):
{
"product_id": product1.id,
"pms_board_service_id": board_service1.id,
"adults": True,
}
)

Expand Down Expand Up @@ -349,6 +351,7 @@ def test_pms_bsl_board_service_line_prop_integrity(self):
"product_id": product1.id,
"pms_board_service_id": board_service1.id,
"pms_property_ids": [pms_property2.id],
"adults": True,
}
)

Expand Down
1 change: 1 addition & 0 deletions pms/tests/test_pms_pricelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def setUpClass(cls):
{
"product_id": cls.product1.id,
"pms_board_service_id": cls.board_service1.id,
"adults": True,
}
)

Expand Down
7 changes: 3 additions & 4 deletions pms/tests/test_pms_reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2217,10 +2217,8 @@ def test_reservation_action_cancel_fail(self):
}
)

reservation.state = "cancel"

with self.assertRaises(UserError):
reservation.action_cancel()
with self.assertRaises(ValidationError):
reservation.state = "cancel"

@freeze_time("2012-01-14")
def test_cancelation_reason_noshow(self):
Expand Down Expand Up @@ -3743,6 +3741,7 @@ def test_commission_amount_with_board_service(self):
"pms_board_service_id": self.board_service_test.id,
"product_id": self.product_test1.id,
"amount": 8,
"adults": True,
}
)
self.board_service_room_type = self.env["pms.board.service.room.type"].create(
Expand Down
4 changes: 4 additions & 0 deletions pms/tests/test_pms_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def test_reservation_sale_origin_in_board_service(self):
"product_id": self.product1.id,
"pms_board_service_id": self.board_service1.id,
"amount": 10,
"adults": True,
}
)

Expand Down Expand Up @@ -155,6 +156,7 @@ def test_change_origin_board_service_not_change_reservation_origin(self):
"product_id": self.product1.id,
"pms_board_service_id": self.board_service1.id,
"amount": 10,
"adults": True,
}
)

Expand Down Expand Up @@ -225,6 +227,7 @@ def test_change_origin_board_service_in_sale_channels(self):
"product_id": self.product1.id,
"pms_board_service_id": self.board_service1.id,
"amount": 10,
"adults": True,
}
)

Expand Down Expand Up @@ -304,6 +307,7 @@ def test_change_origin_reservation_change_origin_services(self):
"product_id": self.product1.id,
"pms_board_service_id": self.board_service1.id,
"amount": 10,
"adults": True,
}
)

Expand Down
8 changes: 8 additions & 0 deletions pms/tests/test_pms_wizard_massive_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ def test_one_board_service_room_type_no_board_service(self):
{
"product_id": service_breakfast.id,
"pms_board_service_id": board_service_only_breakfast.id,
"adults": True,
}
)
date_from = fields.date.today()
Expand Down Expand Up @@ -890,6 +891,7 @@ def test_one_board_service_room_type_with_board_service(self):
{
"product_id": service_breakfast.id,
"pms_board_service_id": board_service_only_breakfast.id,
"adults": True,
}
)
date_from = fields.date.today()
Expand Down Expand Up @@ -991,18 +993,21 @@ def test_several_board_service_room_type_no_board_service(self):
{
"product_id": service_breakfast.id,
"pms_board_service_id": board_service_only_breakfast.id,
"adults": True,
}
)
self.env["pms.board.service.line"].create(
{
"product_id": service_breakfast.id,
"pms_board_service_id": board_service_half_board.id,
"adults": True,
}
)
self.env["pms.board.service.line"].create(
{
"product_id": service_dinner.id,
"pms_board_service_id": board_service_half_board.id,
"adults": True,
}
)
date_from = fields.date.today()
Expand Down Expand Up @@ -1114,18 +1119,21 @@ def test_several_board_service_room_type_with_board_service(self):
{
"product_id": service_breakfast.id,
"pms_board_service_id": board_service_only_breakfast.id,
"adults": True,
}
)
self.env["pms.board.service.line"].create(
{
"product_id": service_breakfast.id,
"pms_board_service_id": board_service_half_board.id,
"adults": True,
}
)
self.env["pms.board.service.line"].create(
{
"product_id": service_dinner.id,
"pms_board_service_id": board_service_half_board.id,
"adults": True,
}
)
date_from = fields.date.today()
Expand Down
5 changes: 5 additions & 0 deletions pms/tests/test_product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def test_bs_consumed_on_after(self):
{
"product_id": product.id,
"pms_board_service_id": self.board_service.id,
"adults": True,
}
)
board_service_room_type = self.env["pms.board.service.room.type"].create(
Expand Down Expand Up @@ -105,6 +106,7 @@ def test_bs_consumed_on_before(self):
{
"product_id": product.id,
"pms_board_service_id": self.board_service.id,
"adults": True,
}
)
board_service_room_type = self.env["pms.board.service.room.type"].create(
Expand Down Expand Up @@ -153,6 +155,7 @@ def test_bs_daily_limit_equal(self):
{
"product_id": product.id,
"pms_board_service_id": self.board_service.id,
"adults": True,
}
)
board_service_room_type = self.env["pms.board.service.room.type"].create(
Expand Down Expand Up @@ -203,6 +206,7 @@ def test_bs_daily_limit_lower(self):
{
"product_id": product.id,
"pms_board_service_id": self.board_service.id,
"adults": True,
}
)
board_service_room_type = self.env["pms.board.service.room.type"].create(
Expand Down Expand Up @@ -256,6 +260,7 @@ def test_bs_daily_limit_greater(self):
{
"product_id": product.id,
"pms_board_service_id": self.board_service.id,
"adults": True,
}
)
board_service_room_type = self.env["pms.board.service.room.type"].create(
Expand Down

0 comments on commit 31e8ddc

Please sign in to comment.