From 784cd06b1f1e27d5a50d1bcde8565a43d1491c91 Mon Sep 17 00:00:00 2001 From: QS5ELkMu Date: Fri, 14 Sep 2018 01:41:53 +0200 Subject: [PATCH] [WIP][MIG][11.0] hotel_calendar --- hotel/tests/common.py | 48 +++++------ hotel/tests/test_reservation.py | 4 +- .../inherited_hotel_room_type_availability.py | 2 +- .../hotel_calendar_management_controller.js | 16 ++++ .../hotel_calendar_management_renderer.js | 19 ++--- .../xml/hotel_calendar_management_view.xml | 4 +- .../tests/test_management_calendar.py | 84 +++++++++---------- .../tests/test_product_pricelist.py | 8 +- .../tests/test_reservations_calendar.py | 28 +++---- hotel_calendar/wizard/wizard_reservation.py | 11 +-- 10 files changed, 114 insertions(+), 110 deletions(-) diff --git a/hotel/tests/common.py b/hotel/tests/common.py index b0b27aa1d..85427ec90 100644 --- a/hotel/tests/common.py +++ b/hotel/tests/common.py @@ -156,12 +156,12 @@ class TestHotel(TestMail): }) VRooms = cls.env['hotel.virtual.room'] - cls.hotel_vroom_budget = VRooms.create({ + cls.hotel_room_type_budget = VRooms.create({ 'name': 'Budget Room', 'virtual_code': '001', 'list_price': 50, }) - cls.hotel_vroom_special = VRooms.create({ + cls.hotel_room_type_special = VRooms.create({ 'name': 'Special Room', 'virtual_code': '002', 'list_price': 150, @@ -170,69 +170,69 @@ class TestHotel(TestMail): Rooms = cls.env['hotel.room'] cls.hotel_room_simple_100 = Rooms.create({ 'name': '100', - 'sale_price_type': 'vroom', - 'price_room_type': cls.hotel_vroom_budget.id, + 'sale_price_type': 'room_type', + 'price_room_type': cls.hotel_room_type_budget.id, 'categ_id': cls.hotel_room_type_simple.cat_id.id, 'capacity': 1, }) cls.hotel_room_simple_101 = Rooms.create({ 'name': '101', - 'sale_price_type': 'vroom', - 'price_room_type': cls.hotel_vroom_budget.id, + 'sale_price_type': 'room_type', + 'price_room_type': cls.hotel_room_type_budget.id, 'categ_id': cls.hotel_room_type_simple.cat_id.id, 'capacity': 1, 'sequence': 1, }) cls.hotel_room_double_200 = Rooms.create({ 'name': '200', - 'sale_price_type': 'vroom', - 'price_room_type': cls.hotel_vroom_special.id, + 'sale_price_type': 'room_type', + 'price_room_type': cls.hotel_room_type_special.id, 'categ_id': cls.hotel_room_type_double.cat_id.id, 'capacity': 2, }) - cls.hotel_vroom_budget.write({ + cls.hotel_room_type_budget.write({ 'room_ids': [(6, False, [cls.hotel_room_simple_100.id, cls.hotel_room_simple_101.id])], }) - cls.hotel_vroom_special.write({ + cls.hotel_room_type_special.write({ 'room_ids': [(6, False, [cls.hotel_room_double_200.id])], }) # Create a week of fresh data now_utc_dt = date_utils.now() cls.avails_tmp = { - cls.hotel_vroom_budget.id: (1, 2, 2, 1, 1, 2, 2), - cls.hotel_vroom_special.id: (1, 1, 1, 1, 1, 1, 1), + cls.hotel_room_type_budget.id: (1, 2, 2, 1, 1, 2, 2), + cls.hotel_room_type_special.id: (1, 1, 1, 1, 1, 1, 1), } cls.prices_tmp = { - cls.hotel_vroom_budget.id: (10.0, 80.0, 80.0, 95.0, 90.0, 80.0, + cls.hotel_room_type_budget.id: (10.0, 80.0, 80.0, 95.0, 90.0, 80.0, 20.0), - cls.hotel_vroom_special.id: (5.0, 15.0, 15.0, 35.0, 35.0, 10.0, + cls.hotel_room_type_special.id: (5.0, 15.0, 15.0, 35.0, 35.0, 10.0, 10.0), } cls.restrictions_min_stay_tmp = { - cls.hotel_vroom_budget.id: (0, 1, 2, 1, 1, 0, 0), - cls.hotel_vroom_special.id: (3, 1, 0, 2, 0, 1, 4), + cls.hotel_room_type_budget.id: (0, 1, 2, 1, 1, 0, 0), + cls.hotel_room_type_special.id: (3, 1, 0, 2, 0, 1, 4), } - budget_product_id = cls.hotel_vroom_budget.product_id - special_product_id = cls.hotel_vroom_special.product_id + budget_product_id = cls.hotel_room_type_budget.product_id + special_product_id = cls.hotel_room_type_special.product_id product_tmpl_ids = { - cls.hotel_vroom_budget.id: budget_product_id.product_tmpl_id.id, - cls.hotel_vroom_special.id: special_product_id.product_tmpl_id.id, + cls.hotel_room_type_budget.id: budget_product_id.product_tmpl_id.id, + cls.hotel_room_type_special.id: special_product_id.product_tmpl_id.id, } - vroom_avail_obj = cls.env['hotel.room.type.availability'] - vroom_rest_item_obj = cls.env['hotel.room.type.restriction.item'] + room_type_avail_obj = cls.env['hotel.room.type.availability'] + room_type_rest_item_obj = cls.env['hotel.room.type.restriction.item'] pricelist_item_obj = cls.env['product.pricelist.item'] for k_vr, v_vr in cls.avails_tmp.iteritems(): for i in range(0, len(v_vr)): ndate = now_utc_dt + timedelta(days=i) - vroom_avail_obj.create({ + room_type_avail_obj.create({ 'room_type_id': k_vr, 'avail': v_vr[i], 'date': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT) }) - vroom_rest_item_obj.create({ + room_type_rest_item_obj.create({ 'room_type_id': k_vr, 'restriction_id': cls.parity_restrictions_id, 'date_start': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT), diff --git a/hotel/tests/test_reservation.py b/hotel/tests/test_reservation.py index a4ec21534..dc02750e0 100644 --- a/hotel/tests/test_reservation.py +++ b/hotel/tests/test_reservation.py @@ -232,7 +232,7 @@ class TestHotelReservations(TestHotel): # 5.0, 15.0, 15.0, 35.0, 35.0, 10.0, 10.0 - vroom_prices = self.prices_tmp[self.hotel_room_double_200.price_room_type.id] + room_type_prices = self.prices_tmp[self.hotel_room_double_200.price_room_type.id] org_reserv_start_utc_dt = now_utc_dt + timedelta(days=1) org_reserv_end_utc_dt = org_reserv_start_utc_dt + timedelta(days=2) folio = self.create_folio(self.user_hotel_manager, self.partner_2) @@ -246,7 +246,7 @@ class TestHotelReservations(TestHotel): ndate = org_reserv_start_utc_dt for r_k, r_v in enumerate(reservation.reservation_lines): self.assertEqual(r_v.date, ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)) - self.assertEqual(r_v.price, vroom_prices[r_k+1]) + self.assertEqual(r_v.price, room_type_prices[r_k+1]) ndate = ndate + timedelta(days=1) self.assertEqual(reservation.amount_room, 30.0) ndate = org_reserv_start_utc_dt + timedelta(days=1) diff --git a/hotel_calendar/models/inherited_hotel_room_type_availability.py b/hotel_calendar/models/inherited_hotel_room_type_availability.py index bccdf91c2..fa81bf137 100644 --- a/hotel_calendar/models/inherited_hotel_room_type_availability.py +++ b/hotel_calendar/models/inherited_hotel_room_type_availability.py @@ -39,7 +39,7 @@ class HotelRoomTypeAvailability(models.Model): for record in self: unlink_vals.append({ 'date': record.date, - 'avail': record.room_type_id.max_real_rooms, + 'avail': record.room_type_id.total_rooms_count, 'room_type_id': record.room_type_id.id, 'no_ota': False, 'id': record.id, diff --git a/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_controller.js b/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_controller.js index 5e26006fd..131de33c5 100644 --- a/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_controller.js +++ b/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_controller.js @@ -17,6 +17,7 @@ var MPMSCalendarController = AbstractController.extend({ onSaveChanges: '_onSaveChanges', onLoadCalendar: '_onLoadCalendar', onLoadCalendarSettings: '_onLoadCalendarSettings', + onLoadNewContentCalendar: '_onLoadNewContentCalendar', }), /** * @override @@ -62,6 +63,21 @@ var MPMSCalendarController = AbstractController.extend({ }); }, + _onLoadNewContentCalendar: function (ev) { + var self = this; + var params = this.renderer.generate_params(); + var oparams = [params['dates'][0], params['dates'][1], params['prices'], params['restrictions'], false]; + + this.model.get_hcalendar_data(oparams).then(function(results){ + self.renderer._days_tooltips = results['events']; + self.renderer._hcalendar.setData(results['prices'], results['restrictions'], results['availability'], results['count_reservations']); + self.renderer._assign_extra_info(); + }); + this.renderer._last_dates = params['dates']; + this.renderer.$CalendarHeaderDays = this.renderer.$el.find("div.table-room_type-data-header"); + this.renderer._on_scroll(); // FIXME: Workaround for update sticky header + }, + _onLoadCalendar: function (ev) { var self = this; diff --git a/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_renderer.js b/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_renderer.js index 0cf0ac731..81b7979a5 100644 --- a/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_renderer.js +++ b/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_renderer.js @@ -240,7 +240,7 @@ var HotelCalendarManagementView = AbstractRenderer.extend({ /** VIEW CONTROLS INITIALIZATION **/ // DATE TIME PICKERS - var l10nn = _t.database.parameters + console.log("asdads"); var DTPickerOptions = { viewMode: 'months', icons : { @@ -249,8 +249,9 @@ var HotelCalendarManagementView = AbstractRenderer.extend({ up: 'fa fa-chevron-up', down: 'fa fa-chevron-down' }, + locale : moment.locale(), format : HotelConstants.L10N_DATE_MOMENT_FORMAT, - disabledHours: [0, 1, 2, 3, 4, 5, 6, 7, 8, 18, 19, 20, 21, 22, 23] + //disabledHours: [0, 1, 2, 3, 4, 5, 6, 7, 8, 18, 19, 20, 21, 22, 23] }; var $dateTimePickerBegin = this.$el.find('#mpms-search #date_begin'); var $dateTimePickerEnd = this.$el.find('#mpms-search #date_end'); @@ -263,8 +264,8 @@ var HotelCalendarManagementView = AbstractRenderer.extend({ self.on_change_filter_date(e, true); }); $dateTimePickerEnd.on("dp.change", function (e) { - self.on_change_filter_date(e, false); $dateTimePickerEnd.data("DateTimePicker").hide(); // TODO: Odoo uses old datetimepicker version + self.on_change_filter_date(e, false); }); // var date_begin = moment().startOf('day'); @@ -404,17 +405,7 @@ var HotelCalendarManagementView = AbstractRenderer.extend({ }, reload_hcalendar_management: function() { - var self = this; - var params = this.generate_params(); - var oparams = [params['dates'][0], params['dates'][1], params['prices'], params['restrictions'], false]; - this._model.call('get_hcalendar_all_data', oparams).then(function(results){ - self._days_tooltips = results['events']; - self._hcalendar.setData(results['prices'], results['restrictions'], results['availability'], results['count_reservations']); - self._assign_extra_info(); - }); - this._last_dates = params['dates']; - this.$CalendarHeaderDays = this.$el.find("div.table-room_type-data-header"); - this._on_scroll(); // FIXME: Workaround for update sticky header + this.trigger_up('onLoadNewContentCalendar'); }, generate_params: function() { diff --git a/hotel_calendar/static/src/xml/hotel_calendar_management_view.xml b/hotel_calendar/static/src/xml/hotel_calendar_management_view.xml index 630ff1ace..e932ed36a 100644 --- a/hotel_calendar/static/src/xml/hotel_calendar_management_view.xml +++ b/hotel_calendar/static/src/xml/hotel_calendar_management_view.xml @@ -39,7 +39,7 @@ FROM
- + @@ -48,7 +48,7 @@ TO
- + diff --git a/hotel_calendar/tests/test_management_calendar.py b/hotel_calendar/tests/test_management_calendar.py index 715bd48e5..ed86204a9 100644 --- a/hotel_calendar/tests/test_management_calendar.py +++ b/hotel_calendar/tests/test_management_calendar.py @@ -37,7 +37,7 @@ class TestManagementCalendar(TestHotelCalendar): now_utc_dt = date_utils.now() adv_utc_dt = now_utc_dt + timedelta(days=15) - vrooms = (self.hotel_vroom_budget, self.hotel_vroom_special) + room_types = (self.hotel_room_type_budget, self.hotel_room_type_special) hotel_cal_mngt_obj = self.env['hotel.calendar.management'].sudo( self.user_hotel_manager) @@ -48,14 +48,14 @@ class TestManagementCalendar(TestHotelCalendar): self.parity_pricelist_id, self.parity_restrictions_id, True) - for vroom in vrooms: + for room_type in room_types: for k_pr, v_pr in hcal_data['prices'].iteritems(): - if k_pr == vroom.id: # Only Check Test Cases + if k_pr == room_type.id: # Only Check Test Cases for k_info, v_info in enumerate(v_pr): - if k_info >= len(self.prices_tmp[vroom.id]): + if k_info >= len(self.prices_tmp[room_type.id]): break self.assertEqual(v_info['price'], - self.prices_tmp[vroom.id][k_info], + self.prices_tmp[room_type.id][k_info], "Hotel Calendar Management Prices \ doesn't match!") @@ -63,8 +63,8 @@ class TestManagementCalendar(TestHotelCalendar): prices_obj = self.env['product.pricelist.item'].sudo( self.user_hotel_manager) prod_tmpl_ids = ( - self.hotel_vroom_budget.product_id.product_tmpl_id.id, - self.hotel_vroom_special.product_id.product_tmpl_id.id + self.hotel_room_type_budget.product_id.product_tmpl_id.id, + self.hotel_room_type_special.product_id.product_tmpl_id.id ) pr_ids = prices_obj.search([ ('pricelist_id', '=', self.parity_pricelist_id), @@ -84,7 +84,7 @@ class TestManagementCalendar(TestHotelCalendar): def test_calendar_restrictions(self): now_utc_dt = date_utils.now() adv_utc_dt = now_utc_dt + timedelta(days=15) - vrooms = (self.hotel_vroom_budget, self.hotel_vroom_special) + room_types = (self.hotel_room_type_budget, self.hotel_room_type_special) hotel_cal_mngt_obj = self.env['hotel.calendar.management'].sudo( self.user_hotel_manager) @@ -95,16 +95,16 @@ class TestManagementCalendar(TestHotelCalendar): self.parity_pricelist_id, self.parity_restrictions_id, True) - for vroom in vrooms: + for room_type in room_types: for k_pr, v_pr in hcal_data['restrictions'].iteritems(): - if k_pr == vroom.id: # Only Check Test Cases + if k_pr == room_type.id: # Only Check Test Cases for k_info, v_info in enumerate(v_pr): - rest_items = self.restrictions_min_stay_tmp[vroom.id] + rest_items = self.restrictions_min_stay_tmp[room_type.id] if k_info >= len(rest_items): break self.assertEqual( v_info['min_stay'], - self.restrictions_min_stay_tmp[vroom.id][k_info], + self.restrictions_min_stay_tmp[room_type.id][k_info], "Hotel Calendar Management Restrictions \ doesn't match!") @@ -114,8 +114,8 @@ class TestManagementCalendar(TestHotelCalendar): rest_ids = rest_it_obj.search([ ('applied_on', '=', '0_room_type'), ('restriction_id', '=', self.parity_restrictions_id), - ('room_type_id', 'in', (self.hotel_vroom_budget.id, - self.hotel_vroom_special.id)), + ('room_type_id', 'in', (self.hotel_room_type_budget.id, + self.hotel_room_type_special.id)), ]) rest_ids.sudo(self.user_hotel_manager).unlink() @@ -133,11 +133,11 @@ class TestManagementCalendar(TestHotelCalendar): def test_calendar_availability(self): now_utc_dt = date_utils.now() adv_utc_dt = now_utc_dt + timedelta(days=6) - vrooms = (self.hotel_vroom_budget, self.hotel_vroom_special) + room_types = (self.hotel_room_type_budget, self.hotel_room_type_special) hotel_cal_mngt_obj = self.env['hotel.calendar.management'].sudo( self.user_hotel_manager) - vroom_avail_obj = self.env['hotel.room.type.availability'].sudo( + room_type_avail_obj = self.env['hotel.room.type.availability'].sudo( self.user_hotel_manager) hcal_data = hotel_cal_mngt_obj.get_hcalendar_all_data( @@ -146,22 +146,22 @@ class TestManagementCalendar(TestHotelCalendar): self.parity_pricelist_id, self.parity_restrictions_id, True) - for vroom in vrooms: + for room_type in room_types: for k_pr, v_pr in hcal_data['availability'].iteritems(): - if k_pr == vroom.id: # Only Check Test Cases + if k_pr == room_type.id: # Only Check Test Cases for k_info, v_info in enumerate(v_pr): - if k_info >= len(self.avails_tmp[vroom.id]): + if k_info >= len(self.avails_tmp[room_type.id]): break self.assertEqual( v_info['avail'], - self.avails_tmp[vroom.id][k_info], + self.avails_tmp[room_type.id][k_info], "Hotel Calendar Management Availability \ doesn't match!") # CHANGE AVAIL - avail_ids = vroom_avail_obj.search([ - ('room_type_id', 'in', (self.hotel_vroom_budget.id, - self.hotel_vroom_special.id)), + avail_ids = room_type_avail_obj.search([ + ('room_type_id', 'in', (self.hotel_room_type_budget.id, + self.hotel_room_type_special.id)), ]) for avail_id in avail_ids: avail_id.sudo(self.user_hotel_manager).write({'avail': 1}) @@ -171,9 +171,9 @@ class TestManagementCalendar(TestHotelCalendar): self.parity_pricelist_id, self.parity_restrictions_id, True) - for vroom in vrooms: + for room_type in room_types: for k_pr, v_pr in hcal_data['availability'].iteritems(): - if k_pr == vroom.id: # Only Check Test Cases + if k_pr == room_type.id: # Only Check Test Cases for k_info, v_info in enumerate(v_pr): self.assertEqual( v_info['avail'], @@ -182,9 +182,9 @@ class TestManagementCalendar(TestHotelCalendar): doesn't match!") # REMOVE AVAIL - avail_ids = vroom_avail_obj.search([ - ('room_type_id', 'in', (self.hotel_vroom_budget.id, - self.hotel_vroom_special.id)), + avail_ids = room_type_avail_obj.search([ + ('room_type_id', 'in', (self.hotel_room_type_budget.id, + self.hotel_room_type_special.id)), ]) avail_ids.sudo(self.user_hotel_manager).unlink() @@ -194,20 +194,20 @@ class TestManagementCalendar(TestHotelCalendar): self.parity_pricelist_id, self.parity_restrictions_id, True) - for vroom in vrooms: + for room_type in room_types: for k_pr, v_pr in hcal_data['availability'].iteritems(): - if k_pr == vroom.id: # Only Check Test Cases + if k_pr == room_type.id: # Only Check Test Cases for k_info, v_info in enumerate(v_pr): self.assertEqual( v_info['avail'], - vroom.max_real_rooms, + room_type.max_real_rooms, "Hotel Calendar Management Availability \ doesn't match!") def test_save_changes(self): now_utc_dt = date_utils.now() adv_utc_dt = now_utc_dt + timedelta(days=3) - vrooms = (self.hotel_vroom_budget,) + room_types = (self.hotel_room_type_budget,) hotel_cal_mngt_obj = self.env['hotel.calendar.management'].sudo( self.user_hotel_manager) @@ -217,7 +217,7 @@ class TestManagementCalendar(TestHotelCalendar): cprices = {} for k_item, v_item in enumerate(prices): ndate_utc_dt = now_utc_dt + timedelta(days=k_item) - cprices.setdefault(self.hotel_vroom_budget.id, []).append({ + cprices.setdefault(self.hotel_room_type_budget.id, []).append({ 'date': ndate_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT), 'price': v_item }) @@ -235,7 +235,7 @@ class TestManagementCalendar(TestHotelCalendar): crestrictions = {} for i in range(0, 4): ndate_utc_dt = now_utc_dt + timedelta(days=i) - crestrictions.setdefault(self.hotel_vroom_budget.id, []).append({ + crestrictions.setdefault(self.hotel_room_type_budget.id, []).append({ 'date': ndate_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT), 'closed_arrival': restrictions['closed_arrival'][i], 'max_stay': restrictions['max_stay'][i], @@ -252,7 +252,7 @@ class TestManagementCalendar(TestHotelCalendar): for k_item, v_item in enumerate(avails): ndate_utc_dt = now_utc_dt + timedelta(days=k_item) ndate_dt = date_utils.dt_as_timezone(ndate_utc_dt, self.tz_hotel) - cavails.setdefault(self.hotel_vroom_budget.id, []).append({ + cavails.setdefault(self.hotel_room_type_budget.id, []).append({ 'date': ndate_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), 'avail': v_item, 'no_ota': False, @@ -274,16 +274,16 @@ class TestManagementCalendar(TestHotelCalendar): self.parity_restrictions_id, True) - for vroom in vrooms: + for room_type in room_types: for k_pr, v_pr in hcal_data['availability'].iteritems(): - if k_pr == vroom.id: # Only Check Test Cases + if k_pr == room_type.id: # Only Check Test Cases for k_info, v_info in enumerate(v_pr): self.assertEqual(v_info['avail'], avails[k_info], "Hotel Calendar Management \ Availability doesn't match!") for k_pr, v_pr in hcal_data['restrictions'].iteritems(): - if k_pr == vroom.id: # Only Check Test Cases + if k_pr == room_type.id: # Only Check Test Cases for k_info, v_info in enumerate(v_pr): self.assertEqual(v_info['min_stay'], restrictions['min_stay'][k_info], @@ -319,7 +319,7 @@ class TestManagementCalendar(TestHotelCalendar): "Hotel Calendar Management Restrictions \ doesn't match!") for k_pr, v_pr in hcal_data['prices'].iteritems(): - if k_pr == vroom.id: # Only Check Test Cases + if k_pr == room_type.id: # Only Check Test Cases for k_info, v_info in enumerate(v_pr): self.assertEqual(v_info['price'], prices[k_info], "Hotel Calendar \ @@ -328,7 +328,7 @@ class TestManagementCalendar(TestHotelCalendar): def test_calendar_reservations(self): now_utc_dt = date_utils.now() adv_utc_dt = now_utc_dt + timedelta(days=15) - vrooms = (self.hotel_vroom_budget,) + room_types = (self.hotel_room_type_budget,) hotel_cal_mngt_obj = self.env['hotel.calendar.management'].sudo( self.user_hotel_manager) @@ -352,9 +352,9 @@ class TestManagementCalendar(TestHotelCalendar): True) avail_end_utc_dt = reserv_end_utc_dt - timedelta(days=1) - for vroom in vrooms: + for room_type in room_types: for k_pr, v_pr in hcal_data['count_reservations'].iteritems(): - if k_pr == vroom.id: # Only Check Test Cases + if k_pr == room_type.id: # Only Check Test Cases for k_info, v_info in enumerate(v_pr): ndate = date_utils.get_datetime(v_info['date']) if date_utils.date_in(ndate, diff --git a/hotel_calendar/tests/test_product_pricelist.py b/hotel_calendar/tests/test_product_pricelist.py index 333442732..21695e173 100644 --- a/hotel_calendar/tests/test_product_pricelist.py +++ b/hotel_calendar/tests/test_product_pricelist.py @@ -30,12 +30,12 @@ class TestProductPricelist(TestHotelCalendar): now_utc_dt = date_utils.now() now_utc_str = now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT) - vroom_tmpl_id = self.hotel_vroom_special.product_id.product_tmpl_id + room_type_tmpl_id = self.hotel_room_type_special.product_id.product_tmpl_id pritem_obj = self.env['product.pricelist.item'] plitem = pritem_obj.search([ ('pricelist_id', '=', self.parity_pricelist_id), - ('product_tmpl_id', '=', vroom_tmpl_id.id), + ('product_tmpl_id', '=', room_type_tmpl_id.id), ('date_start', '=', now_utc_str), ('date_end', '=', now_utc_str), ('applied_on', '=', '1_product'), @@ -44,13 +44,13 @@ class TestProductPricelist(TestHotelCalendar): old_price = plitem.fixed_price self.pricelist_1.update_price( - self.hotel_vroom_special.id, + self.hotel_room_type_special.id, now_utc_str, 999.9) plitem = pritem_obj.search([ ('pricelist_id', '=', self.parity_pricelist_id), - ('product_tmpl_id', '=', vroom_tmpl_id.id), + ('product_tmpl_id', '=', room_type_tmpl_id.id), ('date_start', '=', now_utc_str), ('date_end', '=', now_utc_str), ('applied_on', '=', '1_product'), diff --git a/hotel_calendar/tests/test_reservations_calendar.py b/hotel_calendar/tests/test_reservations_calendar.py index 14c8b2d65..9fc4d09d2 100644 --- a/hotel_calendar/tests/test_reservations_calendar.py +++ b/hotel_calendar/tests/test_reservations_calendar.py @@ -46,11 +46,11 @@ class TestReservationsCalendar(TestHotelCalendar): # Check Pricelist Integrity for k_pr, v_pr in hcal_data['pricelist'].iteritems(): - for vroom_pr in v_pr: + for room_type_pr in v_pr: # Only Check Test Cases - if vroom_pr['room'] in self.prices_tmp.keys(): + if room_type_pr['room'] in self.prices_tmp.keys(): sorted_dates = sorted( - vroom_pr['days'].keys(), + room_type_pr['days'].keys(), key=lambda x: datetime.datetime.strptime(x, '%d/%m/%Y') ) init_date_dt = datetime.datetime.strptime( @@ -67,11 +67,11 @@ class TestReservationsCalendar(TestHotelCalendar): "Hotel Calendar don't end in \ the correct date!") - vroom_prices = self.prices_tmp[vroom_pr['room']] - for k_price, v_price in enumerate(vroom_prices): + room_type_prices = self.prices_tmp[room_type_pr['room']] + for k_price, v_price in enumerate(room_type_prices): self.assertEqual( v_price, - vroom_pr['days'][sorted_dates[k_price+1]], + room_type_pr['days'][sorted_dates[k_price+1]], "Hotel Calendar Pricelist doesn't match!") # Check Pricelist Integrity after unlink @@ -80,8 +80,8 @@ class TestReservationsCalendar(TestHotelCalendar): pr_ids = pricelist_item_obj.search([ ('pricelist_id', '=', self.parity_pricelist_id), ('product_tmpl_id', 'in', ( - self.hotel_vroom_budget.product_id.product_tmpl_id.id, - self.hotel_vroom_special.product_id.product_tmpl_id.id)), + self.hotel_room_type_budget.product_id.product_tmpl_id.id, + self.hotel_room_type_special.product_id.product_tmpl_id.id)), ]) pr_ids.sudo(self.user_hotel_manager).unlink() reserv_obj = self.env['hotel.reservation'].sudo( @@ -89,14 +89,14 @@ class TestReservationsCalendar(TestHotelCalendar): hcal_data = reserv_obj.get_hcalendar_all_data( now_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT), adv_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT)) - vrooms = (self.hotel_vroom_budget, self.hotel_vroom_special) - for vroom in vrooms: + room_types = (self.hotel_room_type_budget, self.hotel_room_type_special) + for room_type in room_types: for k_pr, v_pr in hcal_data['pricelist'].iteritems(): - for vroom_pr in v_pr: - if vroom_pr['room'] == vroom.id: # Only Check Test Cases + for room_type_pr in v_pr: + if room_type_pr['room'] == room_type.id: # Only Check Test Cases self.assertEqual( - vroom.list_price, - vroom_pr['days'][sorted_dates[k_price+1]], + room_type.list_price, + room_type_pr['days'][sorted_dates[k_price+1]], "Hotel Calendar Pricelist doesn't \ match after remove!") diff --git a/hotel_calendar/wizard/wizard_reservation.py b/hotel_calendar/wizard/wizard_reservation.py index d7a21cbaf..5b909e740 100644 --- a/hotel_calendar/wizard/wizard_reservation.py +++ b/hotel_calendar/wizard/wizard_reservation.py @@ -306,14 +306,11 @@ class HotelRoomTypeWizards(models.TransientModel): can_confirm = fields.Boolean(compute="_can_confirm") def _can_confirm(self): - for vroom in self: - date_start = date_utils.get_datetime(vroom.checkin) - date_end = date_utils.get_datetime(vroom.checkout) + for room_type in self: + date_start = date_utils.get_datetime(room_type.checkin) + date_end = date_utils.get_datetime(room_type.checkout) date_diff = date_utils.date_diff(date_start, date_end, hours=False) - if vroom.max_rooms > 0 and vroom.min_stay <= date_diff: - vroom.can_confirm = True - else: - vroom.can_confirm = False + room_type.can_confirm = room_type.max_rooms > 0 and room_type.min_stay <= date_diff def _compute_max(self): for res in self: