Merge PR #123 into 14.0

Signed-off-by DarioLodeiros
This commit is contained in:
OCA-git-bot
2022-04-03 10:26:29 +00:00
10 changed files with 195 additions and 17 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 76 KiB

View File

@@ -354,8 +354,8 @@
'adults': 1,
'state': 'confirm',
'reservation_type': 'out',
'closure_reason_id': ref('pms_room_closure_reason_maintenance'),
'out_service_description': 'Door arrangement',
'closure_reason_id': ref('pms_room_closure_reason_vip_privacy'),
'out_service_description': 'Room next to noisy guests.',
})]"
/>
</record>

View File

@@ -9,8 +9,33 @@
<field name="reservation_type">out</field>
<field name="preferred_room_id" ref="pms_room_eco_01" />
<field name="checkin" eval="DateTime.today() + timedelta(-3)" />
<field name="checkout" eval="DateTime.today() + timedelta(-1)" />
<field name="checkout" eval="DateTime.today()" />
<field name="closure_reason_id" ref="pms_room_closure_reason_vip_privacy" />
<field
name="out_service_description"
>Extra privacy for school field trip.</field>
<field name="pms_property_id" ref="pms.main_pms_property" />
</record>
<record id="pms_reservation_double_out_01" model="pms.reservation">
<field name="partner_id" ref="main_pms_property" />
<field name="user_id" ref="base.user_demo" />
<field name="reservation_type">out</field>
<field name="preferred_room_id" ref="pms_room_double_05" />
<field name="checkin" eval="DateTime.today() + timedelta(-3)" />
<field name="checkout" eval="DateTime.today() + timedelta(1)" />
<field name="closure_reason_id" ref="pms_room_closure_reason_maintenance" />
<field name="out_service_description">Carpet replacement.</field>
<field name="pms_property_id" ref="pms.main_pms_property" />
</record>
<record id="pms_reservation_double_out_02" model="pms.reservation">
<field name="partner_id" ref="main_pms_property" />
<field name="user_id" ref="base.user_demo" />
<field name="reservation_type">out</field>
<field name="preferred_room_id" ref="pms_room_double_03" />
<field name="checkin" eval="DateTime.today() + timedelta(-1)" />
<field name="checkout" eval="DateTime.today() + timedelta(1)" />
<field name="closure_reason_id" ref="pms_room_closure_reason_maintenance" />
<field name="out_service_description">Carpet replacement.</field>
<field name="pms_property_id" ref="pms.main_pms_property" />
</record>
<!-- out of service-->
@@ -22,6 +47,7 @@
<field name="checkin" eval="DateTime.today() + timedelta(2)" />
<field name="checkout" eval="DateTime.today() + timedelta(7)" />
<field name="closure_reason_id" ref="pms_room_closure_reason_maintenance" />
<field name="out_service_description">Wall painting.</field>
<field name="pms_property_id" ref="pms.main_pms_property" />
</record>
<!-- done reservations -->
@@ -363,7 +389,7 @@
<field name="preferred_room_id" ref="pms.pms_room_single_04" />
<field name="adults">1</field>
<field name="checkin" eval="DateTime.today() + timedelta(-5)" />
<field name="checkout" eval="DateTime.today() + timedelta(-1)" />
<field name="checkout" eval="DateTime.today() + timedelta(1)" />
<field
name="board_service_room_id"
ref="pms_board_service_room_single_full_board"
@@ -376,14 +402,41 @@
<field name="partner_id" ref="base.res_partner_address_32" />
<field name="reservation_id" ref="pms_reservation_sng_02" />
<field name="arrival" eval="DateTime.today() + timedelta(-5)" />
<field name="departure" eval="DateTime.today() + timedelta(-1)" />
<field name="departure" eval="DateTime.today() + timedelta(1)" />
<field name="state">onboard</field>
</record>
<function model="pms.checkin.partner" name="action_done">
<value eval="[ref('pms_checkin_partner_r_sng_02')]" />
</function>
<!-- 1 nights sng full board service PAST -->
<record id="pms_reservation_sng_03" model="pms.reservation">
<field name="partner_id" ref="base.res_partner_address_27" />
<field name="user_id" ref="base.user_demo" />
<field name="pricelist_id" ref="product.list0" />
<field name="preferred_room_id" ref="pms.pms_room_single_05" />
<field name="adults">1</field>
<field name="checkin" eval="DateTime.today() + timedelta(-1)" />
<field name="checkout" eval="DateTime.today()" />
<field
name="board_service_room_id"
ref="pms_board_service_room_single_full_board"
/>
<field name="pms_property_id" ref="pms.main_pms_property" />
<field name="channel_type_id" ref="pms.main_pms_sale_channel_mail" />
<field name="state">done</field>
</record>
<record id="pms_checkin_partner_r_sng_03" model="pms.checkin.partner">
<field name="partner_id" ref="base.res_partner_address_32" />
<field name="reservation_id" ref="pms_reservation_sng_03" />
<field name="arrival" eval="DateTime.today() + timedelta(-1)" />
<field name="departure" eval="DateTime.today()" />
<field name="state">onboard</field>
</record>
<function model="pms.checkin.partner" name="action_done">
<value eval="[ref('pms_checkin_partner_r_sng_02')]" />
</function>
<!-- 2 nights sng full board service -->
<record id="pms_reservation_sng_03" model="pms.reservation">
<record id="pms_reservation_sng_04" model="pms.reservation">
<field name="partner_id" ref="base.res_partner_address_27" />
<field name="user_id" ref="base.user_demo" />
<field name="pricelist_id" ref="product.list0" />
@@ -409,7 +462,7 @@
<field name="partner_requests">breakfast at 5:00 am </field>
</record>
<!-- 3 nights sng breakfast board service -->
<record id="pms_reservation_sng_04" model="pms.reservation">
<record id="pms_reservation_sng_05" model="pms.reservation">
<field name="partner_id" ref="base.res_partner_address_10" />
<field name="user_id" ref="base.user_admin" />
<field name="pricelist_id" ref="product.list0" />
@@ -423,7 +476,7 @@
}),
]"
/>
<field name="checkin" eval="DateTime.today()" />
<field name="checkin" eval="DateTime.today() + timedelta(-1)" />
<field name="checkout" eval="DateTime.today() + timedelta(3)" />
<field
name="board_service_room_id"
@@ -433,7 +486,7 @@
<field name="agency_id" ref="pms.agency_booking" />
</record>
<!-- 4 nights sng full board service -->
<record id="pms_reservation_sng_05" model="pms.reservation">
<record id="pms_reservation_sng_06" model="pms.reservation">
<field name="partner_id" ref="base.res_partner_address_10" />
<field name="user_id" ref="base.user_admin" />
<field name="pricelist_id" ref="product.list0" />
@@ -450,7 +503,7 @@
<field name="partner_requests">Breakfast to take away. </field>
</record>
<!-- 1 night sng half board service -->
<record id="pms_reservation_sng_06" model="pms.reservation">
<record id="pms_reservation_sng_07" model="pms.reservation">
<field name="partner_id" ref="base.res_partner_address_13" />
<field name="user_id" ref="base.user_demo" />
<field name="pricelist_id" ref="product.list0" />
@@ -466,7 +519,7 @@
<field name="agency_id" ref="pms.agency_airbnb" />
</record>
<!-- 4 nights sng no board service -->
<record id="pms_reservation_sng_07" model="pms.reservation">
<record id="pms_reservation_sng_08" model="pms.reservation">
<field name="partner_id" ref="base.res_partner_address_10" />
<field name="user_id" ref="base.user_demo" />
<field name="pricelist_id" ref="product.list0" />
@@ -479,7 +532,7 @@
<field name="partner_requests">preferably street view</field>
</record>
<!-- 4 nights sng no board service -->
<record id="pms_reservation_sng_08" model="pms.reservation">
<record id="pms_reservation_sng_09" model="pms.reservation">
<field name="partner_id" ref="base.res_partner_address_15" />
<field name="user_id" ref="base.user_admin" />
<field name="pricelist_id" ref="product.list0" />
@@ -491,7 +544,7 @@
<field name="channel_type_id" ref="pms.main_pms_sale_channel_phone" />
</record>
<!-- 1 night sng no board service -->
<record id="pms_reservation_sng_09" model="pms.reservation">
<record id="pms_reservation_sng_10" model="pms.reservation">
<field name="partner_id" ref="base.res_partner_address_10" />
<field name="user_id" ref="base.user_demo" />
<field name="pricelist_id" ref="product.list0" />

View File

@@ -1137,7 +1137,7 @@ class PmsFolio(models.Model):
@api.constrains("name")
def _check_required_partner_name(self):
for record in self:
if not record.partner_name:
if not record.partner_name and record.reservation_type != "out":
raise models.ValidationError(_("You must assign a customer name"))
@api.model

View File

@@ -125,6 +125,7 @@ class PmsReservation(models.Model):
help="Reason why the reservation cannot be made",
related="folio_id.closure_reason_id",
check_pms_properties=True,
readonly=False,
)
company_id = fields.Many2one(
string="Company",
@@ -1670,6 +1671,18 @@ class PmsReservation(models.Model):
record, record.service_ids.service_line_ids
)
@api.constrains("closure_reason_id")
def _check_closure_reason_id(self):
for record in self:
if record.reservation_type == "out":
if not record.closure_reason_id:
raise ValidationError(
_(
"A closure reason is mandatory when reservation"
" type is 'out of service'"
)
)
@api.constrains("reservation_type")
def _check_same_reservation_type(self):
for record in self:
@@ -1802,7 +1815,7 @@ class PmsReservation(models.Model):
default_vals["partner_name"] = folio.partner_name
default_vals["mobile"] = folio.mobile
default_vals["email"] = folio.email
else:
elif vals.get("reservation_type") != "out":
raise ValidationError(_("Partner contact name is required"))
vals.update(default_vals)
elif "pms_property_id" in vals and (
@@ -1819,12 +1832,21 @@ class PmsReservation(models.Model):
folio_vals["partner_name"] = vals.get("partner_name")
folio_vals["mobile"] = vals.get("mobile")
folio_vals["email"] = vals.get("email")
else:
elif vals.get("reservation_type") != "out":
raise ValidationError(_("Partner contact name is required"))
# Create the folio in case of need
# (To allow to create reservations direct)
if vals.get("reservation_type"):
folio_vals["reservation_type"] = vals.get("reservation_type")
if vals.get("reservation_type") == "out" and not vals.get(
"closure_reason_id"
):
raise ValidationError(
_(
"A closure reason is mandatory when reservation"
" type is 'out of service'"
)
)
folio = self.env["pms.folio"].create(folio_vals)
vals.update(
{
@@ -1832,6 +1854,7 @@ class PmsReservation(models.Model):
"reservation_type": vals.get("reservation_type"),
}
)
else:
raise ValidationError(_("The Property are mandatory in the reservation"))
if vals.get("name", _("New")) == _("New") or "name" not in vals:

View File

@@ -565,6 +565,12 @@ class TestPmsFolio(TestPms):
checkin = fields.date.today()
checkout = fields.date.today() + datetime.timedelta(days=3)
self.partner1 = self.env["res.partner"].create({"name": "Pedro"})
closure_reason = self.env["room.closure.reason"].create(
{
"name": "test closure reason",
"description": "test clopsure reason description",
}
)
# ACT
reservation = self.env["pms.reservation"].create(
{
@@ -575,6 +581,7 @@ class TestPmsFolio(TestPms):
"pms_property_id": self.pms_property1.id,
"pricelist_id": self.pricelist1.id,
"reservation_type": "out",
"closure_reason_id": closure_reason.id,
}
)
# ASSERT

View File

@@ -1234,6 +1234,12 @@ class TestPmsFolioSaleLine(TestPms):
self.partner1 = self.env["res.partner"].create({"name": "Alberto"})
checkin = fields.date.today()
checkout = fields.date.today() + datetime.timedelta(days=3)
closure_reason = self.env["room.closure.reason"].create(
{
"name": "test closure reason",
"description": "test clopsure reason description",
}
)
# ACT
reservation = self.env["pms.reservation"].create(
{
@@ -1244,6 +1250,7 @@ class TestPmsFolioSaleLine(TestPms):
"pms_property_id": self.pms_property1.id,
"pricelist_id": self.pricelist1.id,
"reservation_type": "out",
"closure_reason_id": closure_reason.id,
}
)
# ASSERT

View File

@@ -3062,6 +3062,12 @@ class TestPmsReservations(TestPms):
# ARRANGE
checkin = fields.date.today()
checkout = fields.date.today() + datetime.timedelta(days=3)
closure_reason = self.env["room.closure.reason"].create(
{
"name": "test closure reason",
"description": "test clopsure reason description",
}
)
# ACT
self.room_type_double.write({"list_price": 30})
reservation = self.env["pms.reservation"].create(
@@ -3073,6 +3079,7 @@ class TestPmsReservations(TestPms):
"pms_property_id": self.pms_property1.id,
"pricelist_id": self.pricelist1.id,
"reservation_type": "out",
"closure_reason_id": closure_reason.id,
}
)
# ASSERT
@@ -3119,6 +3126,12 @@ class TestPmsReservations(TestPms):
# ARRANGE
checkin = fields.date.today()
checkout = fields.date.today() + datetime.timedelta(days=3)
closure_reason = self.env["room.closure.reason"].create(
{
"name": "test closure reason",
"description": "test clopsure reason description",
}
)
# ACT
self.room_type_double.write({"list_price": 30})
reservation = self.env["pms.reservation"].create(
@@ -3129,6 +3142,7 @@ class TestPmsReservations(TestPms):
"partner_id": self.partner1.id,
"pms_property_id": self.pms_property1.id,
"reservation_type": "out",
"closure_reason_id": closure_reason.id,
}
)
@@ -3188,6 +3202,12 @@ class TestPmsReservations(TestPms):
# ARRANGE
checkin = fields.date.today()
checkout = fields.date.today() + datetime.timedelta(days=3)
closure_reason = self.env["room.closure.reason"].create(
{
"name": "test closure reason",
"description": "test clopsure reason description",
}
)
# ACT
reservation = self.env["pms.reservation"].create(
{
@@ -3196,6 +3216,7 @@ class TestPmsReservations(TestPms):
"room_type_id": self.room_type_double.id,
"pms_property_id": self.pms_property1.id,
"reservation_type": "out",
"closure_reason_id": closure_reason.id,
"partner_name": "Install furniture",
}
)
@@ -3724,3 +3745,67 @@ class TestPmsReservations(TestPms):
reservation.commission_amount,
"Reservation commission is wrong",
)
def test_closure_reason_out_of_service_mandatory_not(self):
"""
Ouf of service reservation should contain a closure reason id.
-------------
Create a reservation of type out of service and check if there's no
closure reason id should raises an exception.
"""
# ARRANGE
checkin = fields.date.today()
checkout = fields.date.today() + datetime.timedelta(days=1)
# ACT & ASSERT
with self.assertRaises(
ValidationError,
msg="The reservation has been created and it shouldn't, "
"because it doesn't have a closure reason.",
):
self.env["pms.reservation"].create(
{
"checkin": checkin,
"checkout": checkout,
"room_type_id": self.room_type_double.id,
"partner_id": self.partner1.id,
"pms_property_id": self.pms_property1.id,
"reservation_type": "out",
}
)
def test_closure_reason_out_of_service_mandatory(self):
"""
Ouf of service reservation should contain a closure reason id.
-------------
Create a reservation of type out of service and with a closure reason.
"""
# ARRANGE
checkin = fields.date.today()
checkout = fields.date.today() + datetime.timedelta(days=1)
closure_reason = self.env["room.closure.reason"].create(
{
"name": "Room revision",
"description": "Revision of lights, "
"fire extinguishers, smoke detectors and "
"emergency lights",
}
)
# ACT
reservation_out = self.env["pms.reservation"].create(
{
"checkin": checkin,
"checkout": checkout,
"room_type_id": self.room_type_double.id,
"partner_id": self.partner1.id,
"pms_property_id": self.pms_property1.id,
"reservation_type": "out",
"closure_reason_id": closure_reason,
}
)
# ASSERT
self.assertTrue(
reservation_out.closure_reason_id,
"The out of service reservation should be created properly with "
"a closure reason.",
)

View File

@@ -351,7 +351,10 @@
</h3>
<group>
<group string="General Info" name="contact_details">
<field name="partner_id" />
<field
name="partner_id"
attrs="{'invisible':[('reservation_type','in',('out'))]}"
/>
<field
name="document_type"
attrs="{'invisible':[('reservation_type','in',('out'))]}"