mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] pms: change sale_channel_origin of a folio when it has one reservation
This commit is contained in:
committed by
Darío Lodeiros
parent
95eb5bc7e0
commit
cc03cc2d67
@@ -2118,7 +2118,10 @@ class PmsReservation(models.Model):
|
|||||||
for res in self.filtered(lambda r: r.folio_id == folio)
|
for res in self.filtered(lambda r: r.folio_id == folio)
|
||||||
)
|
)
|
||||||
and vals["sale_channel_origin_id"] != folio.sale_channel_origin_id.id
|
and vals["sale_channel_origin_id"] != folio.sale_channel_origin_id.id
|
||||||
and ("force_update_origin" in vals and vals.get("force_update_origin"))
|
and (
|
||||||
|
("force_update_origin" in vals and vals.get("force_update_origin"))
|
||||||
|
or len(folio.reservation_ids) == 1
|
||||||
|
)
|
||||||
):
|
):
|
||||||
folios_to_update_channel += folio
|
folios_to_update_channel += folio
|
||||||
return folios_to_update_channel
|
return folios_to_update_channel
|
||||||
|
|||||||
@@ -4158,7 +4158,7 @@ class TestPmsReservations(TestPms):
|
|||||||
@freeze_time("2000-12-01")
|
@freeze_time("2000-12-01")
|
||||||
def test_reservation_no_sale_channel_origin(self):
|
def test_reservation_no_sale_channel_origin(self):
|
||||||
"""
|
"""
|
||||||
Check that you cann't create a reservation without sale_channel_origin
|
Check that you can't create a reservation without sale_channel_origin
|
||||||
"""
|
"""
|
||||||
# ACT & ASSERT
|
# ACT & ASSERT
|
||||||
with self.assertRaises(
|
with self.assertRaises(
|
||||||
@@ -4174,3 +4174,37 @@ class TestPmsReservations(TestPms):
|
|||||||
"checkout": datetime.datetime.now() + datetime.timedelta(days=4),
|
"checkout": datetime.datetime.now() + datetime.timedelta(days=4),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@freeze_time("2000-12-01")
|
||||||
|
def test_one_reservation_change_sale_channel_origin(self):
|
||||||
|
"""
|
||||||
|
Check that when changing the sale_channel_origin of a reservation,
|
||||||
|
sale_channel_origin of its folio changes if folio only has one reservation
|
||||||
|
"""
|
||||||
|
# ARRANGE
|
||||||
|
sale_channel_phone = self.env["pms.sale.channel"].create(
|
||||||
|
{
|
||||||
|
"name": "phone",
|
||||||
|
"channel_type": "direct",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
reservation_vals = {
|
||||||
|
"checkin": datetime.datetime.now(),
|
||||||
|
"checkout": datetime.datetime.now() + datetime.timedelta(days=4),
|
||||||
|
"room_type_id": self.room_type_double.id,
|
||||||
|
"partner_id": self.partner1.id,
|
||||||
|
"pms_property_id": self.pms_property1.id,
|
||||||
|
"sale_channel_origin_id": self.sale_channel_direct.id,
|
||||||
|
}
|
||||||
|
reservation1 = self.env["pms.reservation"].create(reservation_vals)
|
||||||
|
|
||||||
|
# ACT
|
||||||
|
reservation1.sale_channel_origin_id = sale_channel_phone.id
|
||||||
|
|
||||||
|
# ASSERT
|
||||||
|
self.assertEqual(
|
||||||
|
reservation1.folio_id.sale_channel_origin_id,
|
||||||
|
reservation1.sale_channel_origin_id,
|
||||||
|
"Sale_channel_origin_id of folio must be the same as "
|
||||||
|
"sale_channel_origin of rservation",
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user