[FIX] pms: tests corrections

This commit is contained in:
FrankC013
2024-05-08 16:29:35 +02:00
committed by Darío Lodeiros
parent f321d07360
commit b33af4d4ea
11 changed files with 42 additions and 8 deletions

View File

@@ -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"))

View File

@@ -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>

View File

@@ -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(

View File

@@ -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,
}
)

View File

@@ -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(

View File

@@ -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,
}
)

View File

@@ -73,6 +73,7 @@ class TestPmsPricelist(TestPms):
{
"product_id": cls.product1.id,
"pms_board_service_id": cls.board_service1.id,
"adults": True,
}
)

View File

@@ -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(

View File

@@ -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,
}
)

View File

@@ -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()

View File

@@ -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(