diff --git a/pms/models/pms_board_service_line.py b/pms/models/pms_board_service_line.py index bba4abd1a..fa130cb8f 100644 --- a/pms/models/pms_board_service_line.py +++ b/pms/models/pms_board_service_line.py @@ -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): @@ -123,3 +124,9 @@ class PmsBoardServiceLine(models.Model): } ) 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")) diff --git a/pms/static/description/index.html b/pms/static/description/index.html index 7f9f245c0..00ef378e4 100644 --- a/pms/static/description/index.html +++ b/pms/static/description/index.html @@ -1,4 +1,3 @@ - diff --git a/pms/tests/test_pms_booking_engine.py b/pms/tests/test_pms_booking_engine.py index 8ccebc854..2f8538240 100644 --- a/pms/tests/test_pms_booking_engine.py +++ b/pms/tests/test_pms_booking_engine.py @@ -758,7 +758,7 @@ class TestPmsBookingEngine(TestPms): 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( @@ -766,6 +766,7 @@ class TestPmsBookingEngine(TestPms): "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( @@ -844,7 +845,7 @@ class TestPmsBookingEngine(TestPms): 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( @@ -852,6 +853,7 @@ class TestPmsBookingEngine(TestPms): "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( diff --git a/pms/tests/test_pms_folio_invoice.py b/pms/tests/test_pms_folio_invoice.py index a20973c50..ef8387f26 100644 --- a/pms/tests/test_pms_folio_invoice.py +++ b/pms/tests/test_pms_folio_invoice.py @@ -488,6 +488,7 @@ class TestPmsFolioInvoice(TestPms): "product_id": self.product1.id, "pms_board_service_id": self.board_service1.id, "amount": 10, + "adults": True, } ) @@ -545,6 +546,7 @@ class TestPmsFolioInvoice(TestPms): "product_id": self.product1.id, "pms_board_service_id": self.board_service1.id, "amount": 10, + "adults": True, } ) @@ -603,6 +605,7 @@ class TestPmsFolioInvoice(TestPms): "product_id": self.product1.id, "pms_board_service_id": self.board_service1.id, "amount": 10, + "adults": True, } ) @@ -759,6 +762,7 @@ class TestPmsFolioInvoice(TestPms): "product_id": self.product1.id, "pms_board_service_id": self.board_service1.id, "amount": 10, + "adults": True, } ) @@ -862,6 +866,7 @@ class TestPmsFolioInvoice(TestPms): "product_id": self.product1.id, "pms_board_service_id": self.board_service1.id, "amount": 10, + "adults": True, } ) diff --git a/pms/tests/test_pms_folio_sale_line.py b/pms/tests/test_pms_folio_sale_line.py index b8d4086b2..86617d6ef 100644 --- a/pms/tests/test_pms_folio_sale_line.py +++ b/pms/tests/test_pms_folio_sale_line.py @@ -67,6 +67,7 @@ class TestPmsFolioSaleLine(TestPms): "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( diff --git a/pms/tests/test_pms_multiproperty.py b/pms/tests/test_pms_multiproperty.py index 1f9b84004..de81767fd 100644 --- a/pms/tests/test_pms_multiproperty.py +++ b/pms/tests/test_pms_multiproperty.py @@ -280,6 +280,7 @@ class TestPmsMultiproperty(TestPms): { "product_id": product1.id, "pms_board_service_id": board_service1.id, + "adults": True, } ) @@ -315,6 +316,7 @@ class TestPmsMultiproperty(TestPms): { "product_id": product1.id, "pms_board_service_id": board_service1.id, + "adults": True, } ) @@ -349,6 +351,7 @@ class TestPmsMultiproperty(TestPms): "product_id": product1.id, "pms_board_service_id": board_service1.id, "pms_property_ids": [pms_property2.id], + "adults": True, } ) diff --git a/pms/tests/test_pms_pricelist.py b/pms/tests/test_pms_pricelist.py index 5ff97a8a3..76bb8cfac 100644 --- a/pms/tests/test_pms_pricelist.py +++ b/pms/tests/test_pms_pricelist.py @@ -73,6 +73,7 @@ class TestPmsPricelist(TestPms): { "product_id": cls.product1.id, "pms_board_service_id": cls.board_service1.id, + "adults": True, } ) diff --git a/pms/tests/test_pms_reservation.py b/pms/tests/test_pms_reservation.py index 684399159..edb02820d 100644 --- a/pms/tests/test_pms_reservation.py +++ b/pms/tests/test_pms_reservation.py @@ -2217,10 +2217,8 @@ class TestPmsReservations(TestPms): } ) - 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): @@ -3743,6 +3741,7 @@ class TestPmsReservations(TestPms): "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( diff --git a/pms/tests/test_pms_service.py b/pms/tests/test_pms_service.py index 27313b84a..3a2e21516 100644 --- a/pms/tests/test_pms_service.py +++ b/pms/tests/test_pms_service.py @@ -89,6 +89,7 @@ class TestPmsService(TestPms): "product_id": self.product1.id, "pms_board_service_id": self.board_service1.id, "amount": 10, + "adults": True, } ) @@ -155,6 +156,7 @@ class TestPmsService(TestPms): "product_id": self.product1.id, "pms_board_service_id": self.board_service1.id, "amount": 10, + "adults": True, } ) @@ -225,6 +227,7 @@ class TestPmsService(TestPms): "product_id": self.product1.id, "pms_board_service_id": self.board_service1.id, "amount": 10, + "adults": True, } ) @@ -304,6 +307,7 @@ class TestPmsService(TestPms): "product_id": self.product1.id, "pms_board_service_id": self.board_service1.id, "amount": 10, + "adults": True, } ) diff --git a/pms/tests/test_pms_wizard_massive_changes.py b/pms/tests/test_pms_wizard_massive_changes.py index a7d55e8f7..5b8d930b8 100644 --- a/pms/tests/test_pms_wizard_massive_changes.py +++ b/pms/tests/test_pms_wizard_massive_changes.py @@ -813,6 +813,7 @@ class TestPmsWizardMassiveChanges(TestPms): { "product_id": service_breakfast.id, "pms_board_service_id": board_service_only_breakfast.id, + "adults": True, } ) date_from = fields.date.today() @@ -890,6 +891,7 @@ class TestPmsWizardMassiveChanges(TestPms): { "product_id": service_breakfast.id, "pms_board_service_id": board_service_only_breakfast.id, + "adults": True, } ) date_from = fields.date.today() @@ -991,18 +993,21 @@ class TestPmsWizardMassiveChanges(TestPms): { "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() @@ -1114,18 +1119,21 @@ class TestPmsWizardMassiveChanges(TestPms): { "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() diff --git a/pms/tests/test_product_template.py b/pms/tests/test_product_template.py index b097ae879..50265f56f 100644 --- a/pms/tests/test_product_template.py +++ b/pms/tests/test_product_template.py @@ -58,6 +58,7 @@ class TestProductTemplate(TestPms): { "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( @@ -105,6 +106,7 @@ class TestProductTemplate(TestPms): { "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( @@ -153,6 +155,7 @@ class TestProductTemplate(TestPms): { "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( @@ -203,6 +206,7 @@ class TestProductTemplate(TestPms): { "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( @@ -256,6 +260,7 @@ class TestProductTemplate(TestPms): { "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(