diff --git a/pms/models/pms_reservation.py b/pms/models/pms_reservation.py index ade2a0447..0c03053f6 100644 --- a/pms/models/pms_reservation.py +++ b/pms/models/pms_reservation.py @@ -2085,7 +2085,7 @@ class PmsReservation(models.Model): lines_to_update_channel = self.env["pms.reservation.line"] if "sale_channel_origin_id" in vals: folios_to_update_channel = self.get_folios_to_update_channel(vals) - lines_to_update_channel = self.get_lines_to_update_channel(vals) + lines_to_update_channel = self.get_lines_to_update_channel(vals) res = super(PmsReservation, self).write(vals) if folios_to_update_channel: folios_to_update_channel.sale_channel_origin_id = vals[ diff --git a/pms/models/pms_reservation_line.py b/pms/models/pms_reservation_line.py index 367c95fcf..0b547b6cd 100644 --- a/pms/models/pms_reservation_line.py +++ b/pms/models/pms_reservation_line.py @@ -112,6 +112,7 @@ class PmsReservationLine(models.Model): store=True, readonly=False, compute="_compute_overbooking", + ) sale_channel_id = fields.Many2one( string="Sale Channel", help="Sale Channel through which reservation line was created", diff --git a/pms/tests/test_pms_availability_plan_rules.py b/pms/tests/test_pms_availability_plan_rules.py index 3bb5c2c62..58fc94ab6 100644 --- a/pms/tests/test_pms_availability_plan_rules.py +++ b/pms/tests/test_pms_availability_plan_rules.py @@ -25,7 +25,13 @@ class TestPmsRoomTypeAvailabilityRules(TestPms): ], } ) - + # pms.sale.channel + self.sale_channel_direct1 = self.env["pms.sale.channel"].create( + { + "name": "Door", + "channel_type": "direct", + } + ) # pms.availability.plan self.test_room_type_availability1 = self.env["pms.availability.plan"].create( { @@ -164,6 +170,7 @@ class TestPmsRoomTypeAvailabilityRules(TestPms): "checkout": checkout, "partner_id": self.partner1.id, "room_type_id": room_type.id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) result = self.test_room_type_availability_rule1.plan_avail @@ -209,6 +216,7 @@ class TestPmsRoomTypeAvailabilityRules(TestPms): "checkout": checkout, "partner_id": self.partner1.id, "room_type_id": room_type.id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) self.env["pms.reservation"].create( @@ -218,6 +226,7 @@ class TestPmsRoomTypeAvailabilityRules(TestPms): "checkout": checkout, "partner_id": self.partner1.id, "room_type_id": room_type.id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) result = self.test_room_type_availability_rule1.plan_avail @@ -258,6 +267,7 @@ class TestPmsRoomTypeAvailabilityRules(TestPms): "checkin": checkin, "checkout": checkout, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) @@ -586,6 +596,7 @@ class TestPmsRoomTypeAvailabilityRules(TestPms): "room_type_id": self.test_room_type_double.id, "pricelist_id": self.pricelist2.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) r1.flush() diff --git a/pms/tests/test_pms_checkin_partner.py b/pms/tests/test_pms_checkin_partner.py index 1db2b4ac1..cc0e9d414 100644 --- a/pms/tests/test_pms_checkin_partner.py +++ b/pms/tests/test_pms_checkin_partner.py @@ -68,6 +68,12 @@ class TestPmsCheckinPartner(TestPms): "partner_id": self.host1.id, } ) + self.sale_channel_direct1 = self.env["pms.sale.channel"].create( + { + "name": "Door", + "channel_type": "direct", + } + ) reservation_vals = { "checkin": datetime.date.today(), "checkout": datetime.date.today() + datetime.timedelta(days=3), @@ -75,6 +81,7 @@ class TestPmsCheckinPartner(TestPms): "partner_id": self.host1.id, "adults": 3, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } self.reservation_1 = self.env["pms.reservation"].create(reservation_vals) self.checkin1 = self.env["pms.checkin.partner"].create( @@ -1091,6 +1098,7 @@ class TestPmsCheckinPartner(TestPms): "pms_property_id": self.pms_property1.id, "partner_name": partner.name, "email": partner.email, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) # ACT @@ -1133,6 +1141,7 @@ class TestPmsCheckinPartner(TestPms): "room_type_id": self.room_type1.id, "pms_property_id": self.pms_property1.id, "partner_name": partner.name, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) # ACT @@ -1178,6 +1187,7 @@ class TestPmsCheckinPartner(TestPms): "room_type_id": self.room_type1.id, "pms_property_id": self.pms_property1.id, "partner_name": partner.name, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) checkin = self.env["pms.checkin.partner"].create( @@ -1239,6 +1249,7 @@ class TestPmsCheckinPartner(TestPms): "room_type_id": self.room_type1.id, "pms_property_id": self.pms_property1.id, "partner_name": partner1.name, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -1286,6 +1297,7 @@ class TestPmsCheckinPartner(TestPms): "room_type_id": self.room_type1.id, "pms_property_id": self.pms_property1.id, "partner_name": "Rosa Costa", + "sale_channel_origin_id": self.sale_channel_direct1.id } ) checkin = self.env["pms.checkin.partner"].create( @@ -1539,6 +1551,7 @@ class TestPmsCheckinPartner(TestPms): "partner_id": self.host1.id, "adults": 1, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) checkin_partner_id = self.reservation.checkin_partner_ids[0] diff --git a/pms/tests/test_pms_folio.py b/pms/tests/test_pms_folio.py index 52704bfc8..ba72a4c4a 100644 --- a/pms/tests/test_pms_folio.py +++ b/pms/tests/test_pms_folio.py @@ -55,6 +55,15 @@ class TestPmsFolio(TestPms): ) journals.allowed_pms_payments = True + # create sale channel direct + self.sale_channel_direct1 = self.env["pms.sale.channel"].create( + { + "name": "Door", + "channel_type": "direct", + } + ) + + def create_sale_channel_scenario(self): """ Method to simplified scenario on sale channel tests: @@ -410,6 +419,7 @@ class TestPmsFolio(TestPms): "adults": 2, "partner_id": self.env.ref("base.res_partner_12").id, "room_type_id": self.demo_room_type_double.id, + "sale_channel_origin_id":self.sale_channel_direct1.id, } ) @@ -456,6 +466,7 @@ class TestPmsFolio(TestPms): "adults": 2, "partner_id": self.env.ref("base.res_partner_12").id, "room_type_id": self.demo_room_type_double.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -542,6 +553,7 @@ class TestPmsFolio(TestPms): "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist1.id, "reservation_type": "staff", + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) # ASSERT @@ -582,6 +594,7 @@ class TestPmsFolio(TestPms): "pricelist_id": self.pricelist1.id, "reservation_type": "out", "closure_reason_id": closure_reason.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) # ASSERT diff --git a/pms/tests/test_pms_folio_invoice.py b/pms/tests/test_pms_folio_invoice.py index c5d509a7e..1db34077f 100644 --- a/pms/tests/test_pms_folio_invoice.py +++ b/pms/tests/test_pms_folio_invoice.py @@ -135,6 +135,14 @@ class TestPmsFolioInvoice(TestPms): ) journals.allowed_pms_payments = True + # create a sale channel + self.sale_channel_direct1 = self.env["pms.sale.channel"].create( + { + "name": "Door", + "channel_type": "direct", + } + ) + def test_invoice_full_folio(self): """ Check that when launching the create_invoices() method for a full folio, @@ -153,6 +161,7 @@ class TestPmsFolioInvoice(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner_id.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) state_expected = "invoiced" @@ -183,6 +192,7 @@ class TestPmsFolioInvoice(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner_id.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) dict_lines = dict() @@ -208,6 +218,7 @@ class TestPmsFolioInvoice(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner_id.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) dict_lines = dict() @@ -260,6 +271,7 @@ class TestPmsFolioInvoice(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) tcs = [-1, 0, 3] @@ -294,6 +306,7 @@ class TestPmsFolioInvoice(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner_id.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -321,6 +334,7 @@ class TestPmsFolioInvoice(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner_id.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) qty_to_invoice_expected = sum( @@ -348,6 +362,7 @@ class TestPmsFolioInvoice(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner_id.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1.folio_id._create_invoices() @@ -376,6 +391,8 @@ class TestPmsFolioInvoice(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner_id.id, + "service_ids": [(6, 0, [self.service1.id])], + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -418,6 +435,8 @@ class TestPmsFolioInvoice(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner_id.id, + "service_ids": [(6, 0, [self.service1.id])], + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -461,6 +480,8 @@ class TestPmsFolioInvoice(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner_id.id, + "service_ids": [(6, 0, [self.service1.id])], + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -523,6 +544,7 @@ class TestPmsFolioInvoice(TestPms): "room_type_id": self.room_type_double.id, "partner_id": self.partner_id.id, "board_service_room_id": self.board_service_room_type1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) dict_lines = dict() @@ -578,6 +600,7 @@ class TestPmsFolioInvoice(TestPms): "room_type_id": self.room_type_double.id, "partner_id": self.partner_id.id, "board_service_room_id": self.board_service_room_type1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) dict_lines = dict() @@ -634,6 +657,7 @@ class TestPmsFolioInvoice(TestPms): "room_type_id": self.room_type_double.id, "partner_id": self.partner_id.id, "board_service_room_id": self.board_service_room_type1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) dict_lines = dict() diff --git a/pms/tests/test_pms_folio_sale_line.py b/pms/tests/test_pms_folio_sale_line.py index b329d93f1..df733b2f4 100644 --- a/pms/tests/test_pms_folio_sale_line.py +++ b/pms/tests/test_pms_folio_sale_line.py @@ -81,6 +81,12 @@ class TestPmsFolioSaleLine(TestPms): } ) + self.sale_channel_direct1 = self.env["pms.sale.channel"].create( + { + "name": "Door", + "channel_type": "direct", + } + ) # RESERVATION LINES def test_comp_fsl_rooms_all_same_group(self): """ @@ -129,6 +135,7 @@ class TestPmsFolioSaleLine(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) @@ -160,6 +167,7 @@ class TestPmsFolioSaleLine(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) @@ -196,6 +204,7 @@ class TestPmsFolioSaleLine(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) @@ -234,6 +243,7 @@ class TestPmsFolioSaleLine(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) @@ -268,6 +278,7 @@ class TestPmsFolioSaleLine(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) @@ -304,6 +315,7 @@ class TestPmsFolioSaleLine(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) r_test.flush() @@ -342,6 +354,7 @@ class TestPmsFolioSaleLine(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) r_test.flush() @@ -383,6 +396,7 @@ class TestPmsFolioSaleLine(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) r_test.flush() @@ -426,6 +440,7 @@ class TestPmsFolioSaleLine(TestPms): "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, "board_service_room_id": self.board_service_room_type.id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) @@ -464,6 +479,7 @@ class TestPmsFolioSaleLine(TestPms): "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, "board_service_room_id": self.board_service_room_type.id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) r_test.service_ids[0].service_line_ids[0].price_unit = 1.0 @@ -503,6 +519,7 @@ class TestPmsFolioSaleLine(TestPms): "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, "board_service_room_id": self.board_service_room_type.id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) @@ -545,6 +562,7 @@ class TestPmsFolioSaleLine(TestPms): "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, "board_service_room_id": self.board_service_room_type.id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) @@ -586,6 +604,7 @@ class TestPmsFolioSaleLine(TestPms): "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, "board_service_room_id": self.board_service_room_type.id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) @@ -628,6 +647,7 @@ class TestPmsFolioSaleLine(TestPms): "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, "board_service_room_id": self.board_service_room_type.id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) previous_folio_board_service_sale_line = r_test.folio_id.sale_line_ids.filtered( @@ -670,6 +690,7 @@ class TestPmsFolioSaleLine(TestPms): "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, "board_service_room_id": self.board_service_room_type.id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) @@ -713,6 +734,7 @@ class TestPmsFolioSaleLine(TestPms): "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, "board_service_room_id": self.board_service_room_type.id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) @@ -756,6 +778,7 @@ class TestPmsFolioSaleLine(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) # ACT @@ -797,6 +820,7 @@ class TestPmsFolioSaleLine(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) r_test.service_ids = [(4, self.extra_service.id)] @@ -841,6 +865,7 @@ class TestPmsFolioSaleLine(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) r_test.service_ids = [(4, self.extra_service.id)] @@ -886,6 +911,7 @@ class TestPmsFolioSaleLine(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) r_test.service_ids = [(4, self.extra_service.id)] @@ -929,6 +955,7 @@ class TestPmsFolioSaleLine(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) r_test.service_ids = [(4, self.extra_service.id)] @@ -973,6 +1000,7 @@ class TestPmsFolioSaleLine(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) r_test.service_ids = [(4, self.extra_service.id)] @@ -1016,6 +1044,7 @@ class TestPmsFolioSaleLine(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) r_test.service_ids = [(4, self.extra_service.id)] @@ -1066,6 +1095,7 @@ class TestPmsFolioSaleLine(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) r_test.service_ids = [(4, self.extra_service.id)] @@ -1114,6 +1144,7 @@ class TestPmsFolioSaleLine(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) @@ -1160,6 +1191,7 @@ class TestPmsFolioSaleLine(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.env.ref("base.res_partner_12").id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) @@ -1212,6 +1244,7 @@ class TestPmsFolioSaleLine(TestPms): "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist1.id, "reservation_type": "staff", + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) # ASSERT @@ -1251,6 +1284,7 @@ class TestPmsFolioSaleLine(TestPms): "pricelist_id": self.pricelist1.id, "reservation_type": "out", "closure_reason_id": closure_reason.id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) # ASSERT diff --git a/pms/tests/test_pms_multiproperty.py b/pms/tests/test_pms_multiproperty.py index e040491a6..6f74d82f7 100644 --- a/pms/tests/test_pms_multiproperty.py +++ b/pms/tests/test_pms_multiproperty.py @@ -828,12 +828,19 @@ class TestPmsMultiproperty(TestPms): "email": "miguel@example.com", } ) + self.sale_channel_direct1 = self.env["pms.sale.channel"].create( + { + "name": "Door", + "channel_type": "direct", + } + ) self.reservation1 = self.env["pms.reservation"].create( { "checkin": fields.date.today(), "checkout": fields.date.today() + datetime.timedelta(days=1), "pms_property_id": self.pms_property1.id, "partner_id": host1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id, } ) diff --git a/pms/tests/test_pms_pricelist.py b/pms/tests/test_pms_pricelist.py index 9a034ccf4..d03f78e5a 100644 --- a/pms/tests/test_pms_pricelist.py +++ b/pms/tests/test_pms_pricelist.py @@ -83,6 +83,14 @@ class TestPmsPricelist(TestPms): self.partner1 = self.env["res.partner"].create({"name": "Carles"}) + # create a sale channel + self.sale_channel_direct1 = self.env["pms.sale.channel"].create( + { + "name": "Door", + "channel_type": "direct", + } + ) + @freeze_time("2000-01-01") def test_board_service_pricelist_item_apply_sale_dates(self): """ @@ -120,6 +128,7 @@ class TestPmsPricelist(TestPms): "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist2.id, "board_service_room_id": self.board_service_room_type1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) # ASSERT @@ -167,6 +176,7 @@ class TestPmsPricelist(TestPms): "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist2.id, "board_service_room_id": self.board_service_room_type1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) # ASSERT @@ -211,6 +221,7 @@ class TestPmsPricelist(TestPms): "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist2.id, "board_service_room_id": self.board_service_room_type1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) # ASSERT @@ -259,6 +270,7 @@ class TestPmsPricelist(TestPms): "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist2.id, "board_service_room_id": self.board_service_room_type1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) # ASSERT @@ -305,6 +317,7 @@ class TestPmsPricelist(TestPms): "preferred_room_id": self.room1.id, "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist2.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) # ASSERT @@ -351,6 +364,7 @@ class TestPmsPricelist(TestPms): "preferred_room_id": self.room1.id, "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist2.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) # ASSERT @@ -393,6 +407,7 @@ class TestPmsPricelist(TestPms): "preferred_room_id": self.room1.id, "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist2.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) # ASSERT @@ -439,6 +454,7 @@ class TestPmsPricelist(TestPms): "preferred_room_id": self.room1.id, "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist2.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) # ASSERT @@ -485,6 +501,7 @@ class TestPmsPricelist(TestPms): "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist2.id, "service_ids": [(0, 0, {"product_id": self.product1.id})], + "sale_channel_origin_id": self.sale_channel_direct1.id } ) # ASSERT @@ -531,6 +548,7 @@ class TestPmsPricelist(TestPms): "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist2.id, "service_ids": [(0, 0, {"product_id": self.product1.id})], + "sale_channel_origin_id": self.sale_channel_direct1.id } ) # ASSERT @@ -573,6 +591,7 @@ class TestPmsPricelist(TestPms): "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist2.id, "service_ids": [(0, 0, {"product_id": self.product1.id})], + "sale_channel_origin_id": self.sale_channel_direct1.id } ) # ASSERT @@ -619,6 +638,7 @@ class TestPmsPricelist(TestPms): "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist2.id, "service_ids": [(0, 0, {"product_id": self.product1.id})], + "sale_channel_origin_id": self.sale_channel_direct1.id } ) # ASSERT @@ -782,6 +802,7 @@ class TestPmsPricelist(TestPms): "preferred_room_id": self.room.id, "pms_property_id": self.pms_property1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) # ACT @@ -1230,6 +1251,7 @@ class TestPmsPricelist(TestPms): "preferred_room_id": self.room.id, "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) reservation_price = reservation.price_subtotal diff --git a/pms/tests/test_pms_reservation.py b/pms/tests/test_pms_reservation.py index f7c6e0f10..1e138da78 100644 --- a/pms/tests/test_pms_reservation.py +++ b/pms/tests/test_pms_reservation.py @@ -90,6 +90,9 @@ class TestPmsReservations(TestPms): self.id_category = self.env["res.partner.id_category"].create( {"name": "DNI", "code": "D"} ) + self.sale_channel_direct = self.env["pms.sale.channel"].create( + {"name": "sale channel direct", "channel_type": "direct"} + ) self.sale_channel1 = self.env["pms.sale.channel"].create( {"name": "saleChannel1", "channel_type": "indirect"} ) @@ -155,6 +158,7 @@ class TestPmsReservations(TestPms): "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, "reservation_line_ids": [ (0, False, {"date": today}), (0, False, {"date": tomorrow}), @@ -197,6 +201,7 @@ class TestPmsReservations(TestPms): "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, } # ACT @@ -226,6 +231,7 @@ class TestPmsReservations(TestPms): "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, } # ACT @@ -262,6 +268,7 @@ class TestPmsReservations(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r_test.flush() @@ -300,6 +307,7 @@ class TestPmsReservations(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r_test.flush() @@ -331,6 +339,7 @@ class TestPmsReservations(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r1.reservation_line_ids[0].room_id = self.room2.id @@ -344,6 +353,7 @@ class TestPmsReservations(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r2.reservation_line_ids[0].room_id = self.room3.id @@ -357,6 +367,7 @@ class TestPmsReservations(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r3.reservation_line_ids[0].room_id = self.room1.id @@ -370,6 +381,7 @@ class TestPmsReservations(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r4.reservation_line_ids[0].room_id = self.room3.id @@ -385,6 +397,7 @@ class TestPmsReservations(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r_test.flush() @@ -419,6 +432,7 @@ class TestPmsReservations(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r1.reservation_line_ids[0].room_id = self.room2.id @@ -432,6 +446,7 @@ class TestPmsReservations(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r2.reservation_line_ids[0].room_id = self.room3.id @@ -445,6 +460,7 @@ class TestPmsReservations(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r3.reservation_line_ids[0].room_id = self.room1.id @@ -458,6 +474,7 @@ class TestPmsReservations(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r4.reservation_line_ids[0].room_id = self.room3.id @@ -471,6 +488,7 @@ class TestPmsReservations(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r5.reservation_line_ids[0].room_id = self.room2.id @@ -485,6 +503,7 @@ class TestPmsReservations(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r_test.flush() @@ -524,6 +543,7 @@ class TestPmsReservations(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r1.reservation_line_ids[0].room_id = self.room1 @@ -566,6 +586,7 @@ class TestPmsReservations(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r1.reservation_line_ids[0].room_id = self.room1 @@ -608,6 +629,7 @@ class TestPmsReservations(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r1.reservation_line_ids[0].room_id = self.room1 @@ -623,6 +645,7 @@ class TestPmsReservations(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r2.reservation_line_ids[0].room_id = self.room2 @@ -638,6 +661,7 @@ class TestPmsReservations(TestPms): "adults": 2, "room_type_id": self.room_type_double.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r3.reservation_line_ids[0].room_id = self.room3 @@ -722,6 +746,7 @@ class TestPmsReservations(TestPms): "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, } ) computed_priority = res.priority @@ -758,6 +783,7 @@ class TestPmsReservations(TestPms): "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -860,6 +886,7 @@ class TestPmsReservations(TestPms): "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -902,6 +929,7 @@ class TestPmsReservations(TestPms): "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) host1 = self.env["res.partner"].create( @@ -971,6 +999,7 @@ class TestPmsReservations(TestPms): "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) host1 = self.env["res.partner"].create( @@ -1032,6 +1061,7 @@ class TestPmsReservations(TestPms): "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) computed_priority = res.priority @@ -1069,6 +1099,7 @@ class TestPmsReservations(TestPms): "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) host1 = self.env["res.partner"].create( @@ -1134,6 +1165,7 @@ class TestPmsReservations(TestPms): "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) host1 = self.env["res.partner"].create( @@ -1209,6 +1241,7 @@ class TestPmsReservations(TestPms): "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) computed_priority = res.priority @@ -1247,6 +1280,7 @@ class TestPmsReservations(TestPms): "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) computed_priority = res.priority @@ -1288,6 +1322,7 @@ class TestPmsReservations(TestPms): "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) host1 = self.env["res.partner"].create( @@ -1366,6 +1401,7 @@ class TestPmsReservations(TestPms): "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) host1 = self.env["res.partner"].create( @@ -1444,6 +1480,7 @@ class TestPmsReservations(TestPms): "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) host1 = self.env["res.partner"].create( @@ -1514,6 +1551,7 @@ class TestPmsReservations(TestPms): "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, } ) # ACT @@ -1539,6 +1577,7 @@ class TestPmsReservations(TestPms): "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -1568,6 +1607,7 @@ class TestPmsReservations(TestPms): "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, } ) @@ -1596,6 +1636,7 @@ class TestPmsReservations(TestPms): "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, } ) # ACT @@ -1618,6 +1659,7 @@ class TestPmsReservations(TestPms): "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, } ) # ACT @@ -1660,6 +1702,7 @@ class TestPmsReservations(TestPms): "room_type_id": self.room_type_double.id, "partner_id": host.id, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r1.flush() @@ -1729,6 +1772,7 @@ class TestPmsReservations(TestPms): "checkout": fields.date.today() + datetime.timedelta(days=305), "partner_id": self.partner1.id, "room_type_id": self.room_type_double.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) r = reservation.checkin @@ -1766,6 +1810,7 @@ class TestPmsReservations(TestPms): "partner_id": self.partner1.id, "room_type_id": self.room_type_double.id, "pricelist_id": self.pricelist1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) self.assertEqual( @@ -1804,6 +1849,7 @@ class TestPmsReservations(TestPms): "checkout": fields.date.today() + datetime.timedelta(days=152), "agency_id": agency.id, "room_type_id": self.room_type_double.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -1871,6 +1917,7 @@ class TestPmsReservations(TestPms): "checkout": fields.date.today() + datetime.timedelta(days=152), "partner_id": self.partner1.id, "room_type_id": self.room_type_double.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -1931,6 +1978,7 @@ class TestPmsReservations(TestPms): "pms_property_id": self.pms_property1.id, "adults": 3, "room_type_id": self.room_type_triple.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) self.checkin1 = self.env["pms.checkin.partner"].create( @@ -2112,6 +2160,7 @@ class TestPmsReservations(TestPms): "checkout": fields.date.today() + datetime.timedelta(days=65), "pms_property_id": self.pms_property1.id, "partner_id": self.host1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) self.reservation2 = self.env["pms.reservation"].create( @@ -2121,6 +2170,7 @@ class TestPmsReservations(TestPms): "pms_property_id": self.pms_property1.id, "partner_id": self.host1.id, "folio_id": self.reservation.folio_id.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) self.assertTrue( @@ -2145,6 +2195,7 @@ class TestPmsReservations(TestPms): "checkout": fields.date.today() + datetime.timedelta(days=65), "pms_property_id": self.pms_property1.id, "partner_id": self.host1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) self.assertFalse( @@ -2175,6 +2226,7 @@ class TestPmsReservations(TestPms): "room_type_id": self.room_type_double.id, "partner_id": self.host1.id, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -2223,6 +2275,7 @@ class TestPmsReservations(TestPms): "partner_id": self.host1.id, "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -2276,6 +2329,7 @@ class TestPmsReservations(TestPms): "partner_id": self.host1.id, "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -2327,6 +2381,7 @@ class TestPmsReservations(TestPms): "partner_id": self.host1.id, "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) reservation.action_cancel() @@ -2365,6 +2420,7 @@ class TestPmsReservations(TestPms): "pms_property_id": self.pms_property1.id, "adults": 3, "room_type_id": self.room_type_triple.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) self.checkin1 = self.env["pms.checkin.partner"].create( @@ -2425,6 +2481,7 @@ class TestPmsReservations(TestPms): "pms_property_id": self.pms_property1.id, "room_type_id": self.room_type_triple.id, "adults": 3, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) self.checkin1 = self.env["pms.checkin.partner"].create( @@ -2479,6 +2536,7 @@ class TestPmsReservations(TestPms): "allowed_checkout": True, "pms_property_id": self.pms_property1.id, "room_type_id": self.room_type_double.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -2512,6 +2570,7 @@ class TestPmsReservations(TestPms): "pms_property_id": self.pms_property1.id, "folio_id": self.folio1.id, "room_type_id": self.room_type_double.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) # ACT AND ASSERT @@ -2605,6 +2664,7 @@ class TestPmsReservations(TestPms): "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist1.id, "service_ids": [self.board_service.id], + "sale_channel_origin_id": self.sale_channel_direct.id, } ) # ACTION @@ -2649,6 +2709,7 @@ class TestPmsReservations(TestPms): "partner_id": self.partner1.id, "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -2705,6 +2766,7 @@ class TestPmsReservations(TestPms): "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist1.id, "service_ids": [self.service.id], + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -2766,6 +2828,7 @@ class TestPmsReservations(TestPms): "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist1.id, "service_ids": [self.board_service.id], + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -2842,6 +2905,7 @@ class TestPmsReservations(TestPms): "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist1.id, "service_ids": [self.service.id, self.board_service.id], + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -2916,6 +2980,7 @@ class TestPmsReservations(TestPms): "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist1.id, "service_ids": [self.service.id, self.board_service.id], + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -2965,6 +3030,7 @@ class TestPmsReservations(TestPms): "partner_id": self.partner1.id, "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -3045,6 +3111,7 @@ class TestPmsReservations(TestPms): "partner_id": self.partner1.id, "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist1.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) diff_days = (checkout - checkin).days @@ -3079,6 +3146,7 @@ class TestPmsReservations(TestPms): "pms_property_id": self.pms_property1.id, "pricelist_id": self.pricelist1.id, "reservation_type": "staff", + "sale_channel_origin_id": self.sale_channel_direct.id, } ) # ASSERT @@ -3118,6 +3186,7 @@ class TestPmsReservations(TestPms): "pricelist_id": self.pricelist1.id, "reservation_type": "out", "closure_reason_id": closure_reason.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) # ASSERT @@ -3147,6 +3216,7 @@ class TestPmsReservations(TestPms): "partner_id": self.partner1.id, "pms_property_id": self.pms_property1.id, "reservation_type": "staff", + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -3183,6 +3253,7 @@ class TestPmsReservations(TestPms): "pms_property_id": self.pms_property1.id, "reservation_type": "out", "closure_reason_id": closure_reason.id, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -3260,6 +3331,7 @@ class TestPmsReservations(TestPms): "reservation_type": "out", "closure_reason_id": closure_reason.id, "partner_name": "Install furniture", + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -3296,6 +3368,7 @@ class TestPmsReservations(TestPms): "mobile": "61568547", "document_type": self.id_category.id, "document_number": "31640132K", + "sale_channel_origin_id": self.sale_channel_direct.id, } ) # ASSERT @@ -3347,6 +3420,7 @@ class TestPmsReservations(TestPms): "partner_name": partner.name, "document_type": self.document_id.category_id.id, "document_number": self.document_id.name, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) # ASSERT @@ -3402,6 +3476,7 @@ class TestPmsReservations(TestPms): "partner_name": partner.name, "document_type": self.document_id.category_id.id, "document_number": self.document_id.name, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) # ASSERT @@ -3440,6 +3515,7 @@ class TestPmsReservations(TestPms): "pms_property_id": self.pms_property1.id, "partner_name": partner.name, "email": partner.email, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) # ASSERT @@ -3477,6 +3553,7 @@ class TestPmsReservations(TestPms): "pms_property_id": self.pms_property1.id, "partner_name": partner.name, "mobile": partner.mobile, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) # ASSERT @@ -3517,6 +3594,7 @@ class TestPmsReservations(TestPms): "pms_property_id": self.pms_property1.id, "partner_name": partner.name, "email": partner.email, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -3535,81 +3613,6 @@ class TestPmsReservations(TestPms): "The partner was not added to the reservation ", ) - # def test_is_modified_reservation(self): - # """ - # Checked that the is_modified_reservation field is correctly set - # to True when the checkin or checkout fields are modified in a - # reservation. - # ---------------------- - # A reservation is created. The checkin and checkout fields of - # the reservation are modified. The state of the boolean - # to_send_mail is changed to False so that the compute of - # the is_modified_reservation field is activated correctly - # and it is verified that the state of this field is True. - # """ - # # ARRANGE - # checkin = fields.date.today() - # checkout = fields.date.today() + datetime.timedelta(days=2) - # reservation_vals = { - # "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 = self.env["pms.reservation"].create(reservation_vals) - # - # # ACT - # writed_checkin = fields.date.today() + datetime.timedelta(days=4) - # writed_checkout = fields.date.today() + datetime.timedelta(days=6) - # reservation.to_send_mail = False - # reservation.update( - # { - # "checkin": writed_checkin, - # "checkout": writed_checkout, - # } - # ) - # - # # ASSERT - # self.assertTrue( - # reservation.is_modified_reservation, - # "is_modified_reservation field should be True ", - # ) - - # @freeze_time("2012-01-14") - # def test_is_not_modified_reservation(self): - # """ - # Checked that the is_modified_reservation field is correctly set - # to False when the reservation is modified but not the checkin - # or checkout fields. - # ---------------------- - # A reservation is created. The adults, arrival_hour and departure_hours - # fields of the reservation are modified.The it is verified that the state - # of this field is False. - # """ - # # ARRANGE - # checkin = fields.date.today() - # checkout = fields.date.today() + datetime.timedelta(days=2) - # reservation_vals = { - # "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 = self.env["pms.reservation"].create(reservation_vals) - # reservation.update( - # {"adults": 1, "arrival_hour": "18:00", "departure_hour": "08:00"} - # ) - - # # ASSERT - # self.assertFalse( - # reservation.is_modified_reservation, - # "is_modified_reservation field should be False ", - # ) - @freeze_time("2012-01-14") def test_not_add_several_possibles_customers(self): """ @@ -3648,6 +3651,7 @@ class TestPmsReservations(TestPms): "pms_property_id": self.pms_property1.id, "partner_name": partner1.name, "email": partner1.email, + "sale_channel_origin_id": self.sale_channel_direct.id, } ) @@ -3688,6 +3692,7 @@ class TestPmsReservations(TestPms): "room_type_id": self.room_type_double.id, "pms_property_id": self.pms_property1.id, "partner_name": "Rosa Costa", + "sale_channel_origin_id": self.sale_channel_direct.id, } ) diff --git a/pms/tests/test_pms_sale_channel.py b/pms/tests/test_pms_sale_channel.py index 70702b53a..af54d5198 100644 --- a/pms/tests/test_pms_sale_channel.py +++ b/pms/tests/test_pms_sale_channel.py @@ -66,66 +66,6 @@ class TestPmsSaleChannel(TestPms): "Reservation with a valid agency should be created.", ) - def test_reservation_with_partner_direct(self): - """ - Reservation create with partner (no agency) and sale channel - 'direct' must be set reservation sale channel to 'direct'. - A reservation with partner and sale channel as 'direct' - should be created. - """ - # ARRANGE - PmsReservation = self.env["pms.reservation"] - PmsSaleChannel = self.env["pms.sale.channel"] - # ACT - sale_channel1 = PmsSaleChannel.create({"channel_type": "direct"}) - partner1 = self.env["res.partner"].create({"name": "partner1"}) - reservation1 = PmsReservation.create( - { - "checkin": datetime.datetime.now(), - "checkout": datetime.datetime.now() + datetime.timedelta(days=3), - "channel_type_id": sale_channel1.id, - "partner_id": partner1.id, - "pms_property_id": self.pms_property1.id, - } - ) - # ASSERT - self.assertEqual( - reservation1.channel_type_id.channel_type, - "direct", - "A reservation with partner and sale channel as 'direct'" - "should be created a 'direct' reservation.", - ) - - def test_reservation_with_partner_indirect(self): - """ - Reservation create with partner (no agency) and sale channel - 'indirect' must be set reservation sale channel to 'direct'. - A reservation with partner and sale channel as 'direct' - should be created. - """ - # ARRANGE - PmsReservation = self.env["pms.reservation"] - PmsSaleChannel = self.env["pms.sale.channel"] - # ACT - sale_channel1 = PmsSaleChannel.create({"channel_type": "indirect"}) - partner1 = self.env["res.partner"].create({"name": "partner1"}) - reservation1 = PmsReservation.create( - { - "checkin": datetime.datetime.now(), - "checkout": datetime.datetime.now() + datetime.timedelta(days=3), - "channel_type_id": sale_channel1.id, - "partner_id": partner1.id, - "pms_property_id": self.pms_property1.id, - } - ) - # ASSERT - self.assertEqual( - reservation1.channel_type_id.channel_type, - "indirect", - "A reservation with partner and sale channel as 'direct'" - "should be created a 'indirect' reservation.", - ) - def test_create_agency_with_sale_channel_indirect(self): """ Agency should be created as partner setted as 'agency' diff --git a/pms/tests/test_pms_wizard_split_join_swap_reservation.py b/pms/tests/test_pms_wizard_split_join_swap_reservation.py index c1f6853ef..60f2f48da 100644 --- a/pms/tests/test_pms_wizard_split_join_swap_reservation.py +++ b/pms/tests/test_pms_wizard_split_join_swap_reservation.py @@ -56,6 +56,15 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): self.partner1 = self.env["res.partner"].create({"name": "Antón"}) + # create a sale channel + self.sale_channel_direct1 = self.env["pms.sale.channel"].create( + { + "name": "Door", + "channel_type": "direct", + } + ) + + # UNIFY TESTS # review def test_unify_reservation_avail_should(self): """ @@ -83,6 +92,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1.flush() @@ -119,6 +129,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r2 = self.env["pms.reservation"].create( @@ -129,6 +140,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1 = self.env["pms.reservation"].create( @@ -139,6 +151,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "room_type_id": self.test_room_type_double.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r2.flush() @@ -164,6 +177,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r2 = self.env["pms.reservation"].create( @@ -174,6 +188,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r2.flush() @@ -215,6 +230,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r2 = self.env["pms.reservation"].create( @@ -225,6 +241,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1.flush() @@ -274,6 +291,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r2 = self.env["pms.reservation"].create( @@ -284,6 +302,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1.flush() @@ -332,6 +351,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r2 = self.env["pms.reservation"].create( @@ -342,6 +362,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1.flush() @@ -394,6 +415,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r2 = self.env["pms.reservation"].create( @@ -404,6 +426,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1.flush() @@ -456,6 +479,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r2 = self.env["pms.reservation"].create( @@ -466,6 +490,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1.flush() @@ -515,6 +540,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -561,6 +587,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -572,6 +599,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r2 = self.env["pms.reservation"].create( @@ -582,6 +610,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1.flush() @@ -633,6 +662,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -644,6 +674,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r2 = self.env["pms.reservation"].create( @@ -654,6 +685,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1.flush() @@ -699,6 +731,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -736,6 +769,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1.flush() @@ -773,6 +807,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1.flush() @@ -819,6 +854,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1.flush() @@ -861,6 +897,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1.flush() @@ -900,6 +937,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1.flush() @@ -930,6 +968,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1.flush() @@ -959,6 +998,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room2.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1 = self.env["pms.reservation"].create( @@ -969,6 +1009,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): "adults": 2, "preferred_room_id": self.room1.id, "partner_id": self.partner1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1.flush() diff --git a/pms/tests/test_product_template.py b/pms/tests/test_product_template.py index 730d77e5f..a2efbf624 100644 --- a/pms/tests/test_product_template.py +++ b/pms/tests/test_product_template.py @@ -31,6 +31,13 @@ class TestProductTemplate(TestPms): "default_code": "BST", } ) + # create a sale channel + self.sale_channel_direct1 = self.env["pms.sale.channel"].create( + { + "name": "Door", + "channel_type": "direct", + } + ) def test_bs_consumed_on_after(self): """ @@ -69,6 +76,7 @@ class TestProductTemplate(TestPms): "pms_property_id": self.pms_property1.id, "partner_id": self.partner.id, "board_service_room_id": board_service_room_type.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) # ASSERT @@ -115,6 +123,7 @@ class TestProductTemplate(TestPms): "pms_property_id": self.pms_property1.id, "partner_id": self.partner.id, "board_service_room_id": board_service_room_type.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) # ASSERT @@ -162,6 +171,7 @@ class TestProductTemplate(TestPms): "pms_property_id": self.pms_property1.id, "partner_id": self.partner.id, "board_service_room_id": board_service_room_type.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) reservation.flush() @@ -211,6 +221,7 @@ class TestProductTemplate(TestPms): "pms_property_id": self.pms_property1.id, "partner_id": self.partner.id, "board_service_room_id": board_service_room_type.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) reservation.flush() @@ -267,6 +278,7 @@ class TestProductTemplate(TestPms): "partner_id": self.partner.id, "board_service_room_id": board_service_room_type.id, "adults": 2, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -298,6 +310,7 @@ class TestProductTemplate(TestPms): "pms_property_id": self.pms_property1.id, "partner_id": self.partner.id, "service_ids": [extra_bed_service.id], + "sale_channel_origin_id": self.sale_channel_direct1.id } ) reservation._check_adults() diff --git a/pms/tests/test_shared_room.py b/pms/tests/test_shared_room.py index 2408805c4..d3061b3a0 100644 --- a/pms/tests/test_shared_room.py +++ b/pms/tests/test_shared_room.py @@ -85,6 +85,15 @@ class TestPmsSharedRoom(TestPms): } ) + # create a sale channel + self.sale_channel_direct1 = self.env["pms.sale.channel"].create( + { + "name": "Door", + "channel_type": "direct", + } + ) + + def test_count_avail_beds_with_room_occupied(self): """ Check that not allow to create a bed reservation with a room occupied @@ -104,6 +113,7 @@ class TestPmsSharedRoom(TestPms): "checkin": today, "checkout": tomorrow, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -137,6 +147,7 @@ class TestPmsSharedRoom(TestPms): "checkin": today, "checkout": tomorrow, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -182,6 +193,7 @@ class TestPmsSharedRoom(TestPms): "checkin": today, "checkout": tomorrow, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -217,6 +229,7 @@ class TestPmsSharedRoom(TestPms): "checkin": today, "checkout": tomorrow, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) res1.flush() @@ -250,6 +263,7 @@ class TestPmsSharedRoom(TestPms): "checkin": today, "checkout": tomorrow, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -285,6 +299,7 @@ class TestPmsSharedRoom(TestPms): "checkin": today, "checkout": tomorrow, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -321,6 +336,7 @@ class TestPmsSharedRoom(TestPms): "checkin": today, "checkout": tomorrow, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -355,6 +371,7 @@ class TestPmsSharedRoom(TestPms): "checkin": today, "checkout": tomorrow, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -370,6 +387,7 @@ class TestPmsSharedRoom(TestPms): "checkin": today, "checkout": tomorrow, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r_test.flush() @@ -394,6 +412,7 @@ class TestPmsSharedRoom(TestPms): "checkin": today, "checkout": tomorrow, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) @@ -410,6 +429,7 @@ class TestPmsSharedRoom(TestPms): "checkin": today, "checkout": tomorrow, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r_test.flush() @@ -435,6 +455,7 @@ class TestPmsSharedRoom(TestPms): "checkin": today, "checkout": tomorrow, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1.action_cancel() @@ -471,6 +492,7 @@ class TestPmsSharedRoom(TestPms): "checkin": today, "checkout": tomorrow, "pms_property_id": self.pms_property1.id, + "sale_channel_origin_id": self.sale_channel_direct1.id } ) r1.action_cancel() diff --git a/pms/wizards/pms_booking_engine.py b/pms/wizards/pms_booking_engine.py index 937d9d79c..193135264 100644 --- a/pms/wizards/pms_booking_engine.py +++ b/pms/wizards/pms_booking_engine.py @@ -237,7 +237,7 @@ class BookingEngine(models.TransientModel): "partner_name": record.partner_name, "pms_property_id": record.pms_property_id.id, "agency_id": record.agency_id.id, - "channel_type_id": record.channel_type_id.id, + "sale_channel_origin_id": record.channel_type_id.id, "segmentation_ids": [(6, 0, record.segmentation_ids.ids)], "internal_comment": record.internal_comment, }