From 42d7ca83f725630a4419b8ef2b615193ac30b5dc Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Wed, 7 Nov 2018 20:44:09 +0100 Subject: [PATCH] [WIP] Refactoring Code --- hotel/data/records.xml | 2 +- hotel/i18n/es.po | 2 +- hotel/models/res_config.py | 12 ++++---- hotel/tests/common.py | 8 +++--- hotel/views/hotel_reservation_views.xml | 15 +++++----- hotel/views/res_config.xml | 4 +-- .../models/hotel_calendar_management.py | 2 +- .../models/inherited_hotel_reservation.py | 2 +- ...erited_hotel_room_type_restriction_item.py | 6 ++-- hotel_calendar/tests/common.py | 2 +- .../tests/test_management_calendar.py | 28 +++++++++---------- hotel_channel_connector/controllers/main.py | 2 +- hotel_channel_connector/i18n/es.po | 2 +- .../models/channel_backend/common.py | 2 +- .../test_hotel_calendar_management_model.py | 4 +-- 15 files changed, 46 insertions(+), 47 deletions(-) diff --git a/hotel/data/records.xml b/hotel/data/records.xml index b37671663..87772c922 100644 --- a/hotel/data/records.xml +++ b/hotel/data/records.xml @@ -10,7 +10,7 @@ model="ir.default" name="set" eval="('res.config.settings', 'default_pricelist_id', 1)"/> - diff --git a/hotel/i18n/es.po b/hotel/i18n/es.po index 0d604e2f8..b895829d6 100644 --- a/hotel/i18n/es.po +++ b/hotel/i18n/es.po @@ -6163,7 +6163,7 @@ msgstr "Nombre del Plan de Restricciones" #. module: hotel #: selection:hotel.wizard.massive.changes,section:0 -#: model:ir.model.fields,field_description:hotel.field_hotel_config_settings_default_restrictions_id +#: model:ir.model.fields,field_description:hotel.field_hotel_config_settings_default_restriction_id #: model:ir.ui.menu,name:hotel.reservation_restriction_menu #: model:ir.ui.view,arch_db:hotel.reservation_restriction_item_view_form #: model:ir.ui.view,arch_db:hotel.reservation_restriction_item_view_tree diff --git a/hotel/models/res_config.py b/hotel/models/res_config.py index ddf792f99..c2541f639 100644 --- a/hotel/models/res_config.py +++ b/hotel/models/res_config.py @@ -21,7 +21,7 @@ class HotelConfiguration(models.TransientModel): default_pricelist_id = fields.Many2one('product.pricelist', 'Product Pricelist') - default_restrictions_id = fields.Many2one('hotel.room.type.restriction', + default_restriction_id = fields.Many2one('hotel.room.type.restriction', 'Restrictions') default_arrival_hour = fields.Char('Default Arrival Hour (GMT)', help="HH:mm Format", default="14:00") @@ -42,8 +42,8 @@ class HotelConfiguration(models.TransientModel): 'res.config.settings', 'default_pricelist_id', self.default_pricelist_id.id) self.env['ir.default'].sudo().set( - 'res.config.settings', 'default_restrictions_id', - self.default_restrictions_id.id) + 'res.config.settings', 'default_restriction_id', + self.default_restriction_id.id) self.env['ir.default'].sudo().set( 'res.config.settings', 'tz_hotel', self.tz_hotel) self.env['ir.default'].sudo().set( @@ -60,8 +60,8 @@ class HotelConfiguration(models.TransientModel): # ONLY FOR v11. DO NOT FORWARD-PORT default_pricelist_id = self.env['ir.default'].sudo().get( 'res.config.settings', 'default_pricelist_id') - default_restrictions_id = self.env['ir.default'].sudo().get( - 'res.config.settings', 'default_restrictions_id') + default_restriction_id = self.env['ir.default'].sudo().get( + 'res.config.settings', 'default_restriction_id') tz_hotel = self.env['ir.default'].sudo().get( 'res.config.settings', 'tz_hotel') default_arrival_hour = self.env['ir.default'].sudo().get( @@ -70,7 +70,7 @@ class HotelConfiguration(models.TransientModel): 'res.config.settings', 'default_departure_hour') res.update( default_pricelist_id=default_pricelist_id, - default_restrictions_id=default_restrictions_id, + default_restriction_id=default_restriction_id, tz_hotel=tz_hotel, default_arrival_hour=default_arrival_hour, default_departure_hour=default_departure_hour, diff --git a/hotel/tests/common.py b/hotel/tests/common.py index 1c342f1dd..99ba08061 100644 --- a/hotel/tests/common.py +++ b/hotel/tests/common.py @@ -97,15 +97,15 @@ class TestHotel(TestMail): # Minimal Hotel Configuration cls.tz_hotel = 'Europe/Madrid' cls.default_pricelist_id = cls.pricelist_1.id - cls.default_restrictions_id = cls.restriction_1.id + cls.default_restriction_id = cls.restriction_1.id cls.env['ir.values'].sudo().set_default('res.config.settings', 'tz_hotel', cls.tz_hotel) cls.env['ir.values'].sudo().set_default('res.config.settings', 'default_pricelist_id', cls.default_pricelist_id) cls.env['ir.values'].sudo().set_default('res.config.settings', - 'default_restrictions_id', - cls.default_restrictions_id) + 'default_restriction_id', + cls.default_restriction_id) # User Groups user_group_hotel_manager = cls.env.ref('hotel.group_hotel_manager') @@ -234,7 +234,7 @@ class TestHotel(TestMail): }) room_type_rest_item_obj.create({ 'room_type_id': k_vr, - 'restriction_id': cls.default_restrictions_id, + 'restriction_id': cls.default_restriction_id, 'date_start': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT), 'date_end': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT), 'applied_on': '0_room_type', diff --git a/hotel/views/hotel_reservation_views.xml b/hotel/views/hotel_reservation_views.xml index 543754875..ac02f2a62 100644 --- a/hotel/views/hotel_reservation_views.xml +++ b/hotel/views/hotel_reservation_views.xml @@ -1,5 +1,12 @@ + + + Hotel Reservation + hotel.reservation + form + tree,form,graph,pivot + @@ -445,14 +452,6 @@ - - - Hotel Reservation - hotel.reservation - form - tree,form,graph,pivot - - diff --git a/hotel/views/res_config.xml b/hotel/views/res_config.xml index 37a86ba1b..168b8f790 100644 --- a/hotel/views/res_config.xml +++ b/hotel/views/res_config.xml @@ -24,13 +24,13 @@
-
diff --git a/hotel_calendar/models/hotel_calendar_management.py b/hotel_calendar/models/hotel_calendar_management.py index cee2666e5..05aa173a5 100644 --- a/hotel_calendar/models/hotel_calendar_management.py +++ b/hotel_calendar/models/hotel_calendar_management.py @@ -270,7 +270,7 @@ class HotelCalendarManagement(models.TransientModel): 'res.config.settings', 'default_pricelist_id') if not restriction_id: restriction_id = self.env['ir.default'].sudo().get( - 'res.config.settings', 'default_restrictions_id') + 'res.config.settings', 'default_restriction_id') pricelist_id = int(pricelist_id) vals.update({'pricelist_id': pricelist_id}) diff --git a/hotel_calendar/models/inherited_hotel_reservation.py b/hotel_calendar/models/inherited_hotel_reservation.py index 986eb85c8..2943174f0 100644 --- a/hotel_calendar/models/inherited_hotel_reservation.py +++ b/hotel_calendar/models/inherited_hotel_reservation.py @@ -157,7 +157,7 @@ class HotelReservation(models.Model): @api.model def get_hcalendar_restrictions_data(self, dfrom, dto): restriction_id = self.env['ir.default'].sudo().get( - 'res.config.settings', 'default_restrictions_id') + 'res.config.settings', 'default_restriction_id') if restriction_id: restriction_id = int(restriction_id) date_start = fields.Date.from_string(dfrom) - timedelta(days=1) diff --git a/hotel_calendar/models/inherited_hotel_room_type_restriction_item.py b/hotel_calendar/models/inherited_hotel_room_type_restriction_item.py index 0e436ce75..48456fc0c 100644 --- a/hotel_calendar/models/inherited_hotel_room_type_restriction_item.py +++ b/hotel_calendar/models/inherited_hotel_room_type_restriction_item.py @@ -12,7 +12,7 @@ class HotelRoomTypeResrtrictionItem(models.Model): def create(self, vals): res = super(HotelRoomTypeResrtrictionItem, self).create(vals) restrictions_default_id = self.env['ir.default'].sudo().get( - 'res.config.settings', 'default_restrictions_id') + 'res.config.settings', 'default_restriction_id') if restrictions_default_id: restrictions_default_id = int(restrictions_default_id) restriction_id = res.restriction_id.id @@ -36,7 +36,7 @@ class HotelRoomTypeResrtrictionItem(models.Model): @api.multi def write(self, vals): restrictions_default_id = self.env['ir.default'].sudo().get( - 'res.config.settings', 'default_restrictions_id') + 'res.config.settings', 'default_restriction_id') if restrictions_default_id: restrictions_default_id = int(restrictions_default_id) ret_vals = super(HotelRoomTypeResrtrictionItem, self).write(vals) @@ -64,7 +64,7 @@ class HotelRoomTypeResrtrictionItem(models.Model): @api.multi def unlink(self): restrictions_default_id = self.env['ir.default'].sudo().get( - 'res.config.settings', 'default_restrictions_id') + 'res.config.settings', 'default_restriction_id') if restrictions_default_id: restrictions_default_id = int(restrictions_default_id) # Construct dictionary with relevant info of removed records diff --git a/hotel_calendar/tests/common.py b/hotel_calendar/tests/common.py index ca7b61af7..a0e771b14 100644 --- a/hotel_calendar/tests/common.py +++ b/hotel_calendar/tests/common.py @@ -32,7 +32,7 @@ class TestHotelCalendar(TestHotel): # Minimal Hotel Calendar Configuration cls.tz_hotel = 'Europe/Madrid' cls.default_pricelist_id = cls.pricelist_1.id - cls.default_restrictions_id = cls.restriction_1.id + cls.default_restriction_id = cls.restriction_1.id cls.env['ir.default'].sudo().set_default('res.config.settings', 'default_arrival_hour', '14:00') diff --git a/hotel_calendar/tests/test_management_calendar.py b/hotel_calendar/tests/test_management_calendar.py index ba4c42cf5..962dc208d 100644 --- a/hotel_calendar/tests/test_management_calendar.py +++ b/hotel_calendar/tests/test_management_calendar.py @@ -46,7 +46,7 @@ class TestManagementCalendar(TestHotelCalendar): now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), self.default_pricelist_id, - self.default_restrictions_id, + self.default_restriction_id, True) for room_type in room_types: for k_pr, v_pr in hcal_data['prices'].iteritems(): @@ -76,7 +76,7 @@ class TestManagementCalendar(TestHotelCalendar): now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), self.default_pricelist_id, - self.default_restrictions_id, + self.default_restriction_id, True) self.assertFalse(any(hcal_data['prices']), "Hotel Calendar Management \ Prices doesn't match after remove!") @@ -93,7 +93,7 @@ class TestManagementCalendar(TestHotelCalendar): now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), self.default_pricelist_id, - self.default_restrictions_id, + self.default_restriction_id, True) for room_type in room_types: for k_pr, v_pr in hcal_data['restrictions'].iteritems(): @@ -113,7 +113,7 @@ class TestManagementCalendar(TestHotelCalendar): self.user_hotel_manager) rest_ids = rest_it_obj.search([ ('applied_on', '=', '0_room_type'), - ('restriction_id', '=', self.default_restrictions_id), + ('restriction_id', '=', self.default_restriction_id), ('room_type_id', 'in', (self.hotel_room_type_budget.id, self.hotel_room_type_special.id)), ]) @@ -123,7 +123,7 @@ class TestManagementCalendar(TestHotelCalendar): now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), self.default_pricelist_id, - self.default_restrictions_id, + self.default_restriction_id, True) self.assertFalse( any(hcal_data['restrictions']), @@ -144,7 +144,7 @@ class TestManagementCalendar(TestHotelCalendar): now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), self.default_pricelist_id, - self.default_restrictions_id, + self.default_restriction_id, True) for room_type in room_types: for k_pr, v_pr in hcal_data['availability'].iteritems(): @@ -169,7 +169,7 @@ class TestManagementCalendar(TestHotelCalendar): now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), self.default_pricelist_id, - self.default_restrictions_id, + self.default_restriction_id, True) for room_type in room_types: for k_pr, v_pr in hcal_data['availability'].iteritems(): @@ -192,7 +192,7 @@ class TestManagementCalendar(TestHotelCalendar): now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), self.default_pricelist_id, - self.default_restrictions_id, + self.default_restriction_id, True) for room_type in room_types: for k_pr, v_pr in hcal_data['availability'].iteritems(): @@ -261,7 +261,7 @@ class TestManagementCalendar(TestHotelCalendar): # Save new values hotel_cal_mngt_obj.save_changes( self.default_pricelist_id, - self.default_restrictions_id, + self.default_restriction_id, cprices, crestrictions, cavails) @@ -271,7 +271,7 @@ class TestManagementCalendar(TestHotelCalendar): now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), self.default_pricelist_id, - self.default_restrictions_id, + self.default_restriction_id, True) for room_type in room_types: @@ -348,7 +348,7 @@ class TestManagementCalendar(TestHotelCalendar): now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), self.default_pricelist_id, - self.default_restrictions_id, + self.default_restriction_id, True) avail_end_utc_dt = reserv_end_utc_dt - timedelta(days=1) @@ -377,21 +377,21 @@ class TestManagementCalendar(TestHotelCalendar): False, adv_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT), self.default_pricelist_id, - self.default_restrictions_id, + self.default_restriction_id, True) with self.assertRaises(ValidationError): hcal_data = hotel_cal_mngt_obj.get_hcalendar_all_data( now_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT), False, self.default_pricelist_id, - self.default_restrictions_id, + self.default_restriction_id, True) with self.assertRaises(ValidationError): hcal_data = hotel_cal_mngt_obj.get_hcalendar_all_data( False, False, self.default_pricelist_id, - self.default_restrictions_id, + self.default_restriction_id, True) hcal_data = hotel_cal_mngt_obj.get_hcalendar_all_data( now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), diff --git a/hotel_channel_connector/controllers/main.py b/hotel_channel_connector/controllers/main.py index 451081f97..af9da9840 100644 --- a/hotel_channel_connector/controllers/main.py +++ b/hotel_channel_connector/controllers/main.py @@ -82,7 +82,7 @@ class website_wubook(http.Controller): wubook_obj.fetch_rooms_values(dfrom, dto) default_restr_id = request.env['ir.default'].sudo().get( - 'res.config.settings', 'default_restrictions_id') + 'res.config.settings', 'default_restriction_id') if default_restr_id: room_type_restr_obj = request.env['hotel.room.type.restriction'] restr_id = room_type_restr_obj.sudo().browse(int(default_restr_id)) diff --git a/hotel_channel_connector/i18n/es.po b/hotel_channel_connector/i18n/es.po index 21340a9a9..c130f313c 100644 --- a/hotel_channel_connector/i18n/es.po +++ b/hotel_channel_connector/i18n/es.po @@ -700,7 +700,7 @@ msgid "Restriction Plans successfully imported" msgstr "Planes de precios importados con éxito" #. module: hotel_wubook_proto -#: model:ir.model.fields,field_description:hotel_wubook_proto.field_wubook_installer_default_default_restrictions_id +#: model:ir.model.fields,field_description:hotel_wubook_proto.field_wubook_installer_default_default_restriction_id msgid "Restrictions" msgstr "Restricciones" diff --git a/hotel_channel_connector/models/channel_backend/common.py b/hotel_channel_connector/models/channel_backend/common.py index 068d03065..c4d8e7ab2 100644 --- a/hotel_channel_connector/models/channel_backend/common.py +++ b/hotel_channel_connector/models/channel_backend/common.py @@ -222,7 +222,7 @@ class ChannelBackend(models.Model): pricelist_id = int(self.env['ir.default'].sudo().get( 'res.config.settings', 'default_pricelist_id')) restriction_id = int(self.env['ir.default'].sudo().get( - 'res.config.settings', 'default_restrictions_id')) + 'res.config.settings', 'default_restriction_id')) room_type_restr_it_obj = self.env['hotel.room.type.restriction.item'] # Secure Wubook Input diff --git a/hotel_channel_connector/tests/test_hotel_calendar_management_model.py b/hotel_channel_connector/tests/test_hotel_calendar_management_model.py index 344098c24..993a944d1 100644 --- a/hotel_channel_connector/tests/test_hotel_calendar_management_model.py +++ b/hotel_channel_connector/tests/test_hotel_calendar_management_model.py @@ -87,7 +87,7 @@ class TestHotelCalendarManagement(TestHotelWubook): # Save new values hotel_cal_mngt_obj.save_changes( self.default_pricelist_id, - self.default_restrictions_id, + self.default_restriction_id, cprices, crestrictions, cavails) @@ -97,7 +97,7 @@ class TestHotelCalendarManagement(TestHotelWubook): now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT), self.default_pricelist_id, - self.default_restrictions_id, + self.default_restriction_id, True) for room_type in room_types: