From e7bbc76dabd68ed7c4d1533c409974c75d0ff758 Mon Sep 17 00:00:00 2001 From: QS5ELkMu Date: Fri, 14 Sep 2018 22:22:15 +0200 Subject: [PATCH] [WIP][MIG][11.0] channel_connector --- hotel_channel_connector/__init__.py | 2 +- hotel_channel_connector/__manifest__.py | 8 ++-- hotel_channel_connector/backend.py | 6 --- .../components/__init__.py | 2 +- hotel_channel_connector/data/menus.xml | 2 +- hotel_channel_connector/data/sequences.xml | 2 +- .../models/channel_backend/common.py | 11 +++++ .../hotel_channel_connector_ota_info.py | 2 +- .../models/hotel_reservation/common.py | 46 +++++++++---------- .../models/hotel_room_type/common.py | 2 +- .../hotel_room_type_availability/common.py | 2 +- .../hotel_room_type_restriction/common.py | 2 +- .../models/product_pricelist/common.py | 2 +- .../views/channel_hotel_reservation_views.xml | 2 +- ...el_hotel_room_type_availability_views.xml} | 2 +- ...nel_hotel_room_type_restriction_views.xml} | 2 +- .../views/channel_product_pricelist_views.xml | 2 +- ...> hotel_channel_connector_issue_views.xml} | 14 +++--- ...otel_channel_connector_ota_info_views.xml} | 2 +- .../views/inherited_hotel_folio_views.xml | 8 ++-- .../inherited_hotel_reservation_views.xml | 9 ++-- ...ed_hotel_room_type_availability_views.xml} | 23 +++++----- ...inherited_product_pricelist_item_views.xml | 2 +- .../inherited_product_pricelist_views.xml | 2 +- ...nherited_reservation_restriction_views.xml | 2 +- .../wizard/wubook_import_availability.xml | 2 +- .../wizard/wubook_installer.xml | 4 +- 27 files changed, 86 insertions(+), 79 deletions(-) delete mode 100644 hotel_channel_connector/backend.py rename hotel_channel_connector/views/{channel_hotel_virtual_room_availability_views.xml => channel_hotel_room_type_availability_views.xml} (92%) rename hotel_channel_connector/views/{channel_hotel_virtual_room_restriction_views.xml => channel_hotel_room_type_restriction_views.xml} (92%) rename hotel_channel_connector/views/{hotel_channel_connector_issue.xml => hotel_channel_connector_issue_views.xml} (86%) rename hotel_channel_connector/views/{wubook_hotel_channel_connector_ota_info.xml => hotel_channel_connector_ota_info_views.xml} (98%) rename hotel_channel_connector/views/{inherited_hotel_virtual_room_availability_views.xml => inherited_hotel_room_type_availability_views.xml} (62%) diff --git a/hotel_channel_connector/__init__.py b/hotel_channel_connector/__init__.py index c541689a3..765cea70e 100644 --- a/hotel_channel_connector/__init__.py +++ b/hotel_channel_connector/__init__.py @@ -1,7 +1,7 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import components from . import controllers from . import models from . import wizard -from . import components diff --git a/hotel_channel_connector/__manifest__.py b/hotel_channel_connector/__manifest__.py index 3b4613cca..2617b3cc5 100644 --- a/hotel_channel_connector/__manifest__.py +++ b/hotel_channel_connector/__manifest__.py @@ -32,8 +32,8 @@ 'views/inherited_reservation_restriction_views.xml', 'views/inherited_reservation_restriction_item_views.xml', 'views/inherited_res_partner_views.xml', - 'views/wubook_channel_info_views.xml', - 'views/wubook_issue_views.xml', + 'views/hotel_channel_connector_ota_info_views.xml', + 'views/hotel_channel_connector_issue_views.xml', 'views/channel_hotel_reservation_views.xml', 'views/channel_hotel_room_type_views.xml', 'views/channel_hotel_room_type_availability_views.xml', @@ -41,8 +41,8 @@ 'views/channel_product_pricelist_views.xml', 'data/menus.xml', 'data/sequences.xml', - 'security/ir.model.access.csv', - 'security/wubook_security.xml', + #'security/ir.model.access.csv', + #'security/wubook_security.xml', # 'views/res_config.xml' ], 'test': [ diff --git a/hotel_channel_connector/backend.py b/hotel_channel_connector/backend.py deleted file mode 100644 index d6ca5f1c7..000000000 --- a/hotel_channel_connector/backend.py +++ /dev/null @@ -1,6 +0,0 @@ -import openerp.addons.connector.backend as backend - - -wubook = backend.Backend('wubook') -# version 1.2 -wubook_1_2_0_0 = backend.Backend(parent=wubook, version='1.2') diff --git a/hotel_channel_connector/components/__init__.py b/hotel_channel_connector/components/__init__.py index 31e003db2..0d9ff44a4 100644 --- a/hotel_channel_connector/components/__init__.py +++ b/hotel_channel_connector/components/__init__.py @@ -1,8 +1,8 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import core from . import backend_adapter from . import binder -from . import core from . import exporter from . import importer diff --git a/hotel_channel_connector/data/menus.xml b/hotel_channel_connector/data/menus.xml index 1abf0e2be..4f0fdc237 100644 --- a/hotel_channel_connector/data/menus.xml +++ b/hotel_channel_connector/data/menus.xml @@ -3,7 +3,7 @@ Hotel Channel Connector OTA's Info - hotel_channel_connector_ota_info + hotel.channel.connector.ota.info form tree,form diff --git a/hotel_channel_connector/data/sequences.xml b/hotel_channel_connector/data/sequences.xml index 414ee197a..1477fd0c2 100644 --- a/hotel_channel_connector/data/sequences.xml +++ b/hotel_channel_connector/data/sequences.xml @@ -2,7 +2,7 @@ - Virtual Room Short Code + Room Type Short Code hotel.room.type 4 diff --git a/hotel_channel_connector/models/channel_backend/common.py b/hotel_channel_connector/models/channel_backend/common.py index 1307e5572..a517ff822 100644 --- a/hotel_channel_connector/models/channel_backend/common.py +++ b/hotel_channel_connector/models/channel_backend/common.py @@ -10,6 +10,17 @@ class ChannelBackend(models.Model): _description = 'Hotel Channel Backend' _inherit = 'connector.backend' + @api.model + def select_versions(self): + """ Available versions in the backend. + Can be inherited to add custom versions. Using this method + to add a version from an ``_inherit`` does not constrain + to redefine the ``version`` field in the ``_inherit`` model. + """ + return [('1.2', '1.2+')] + + version = fields.Selection(selection='select_versions', required=True) + username = fields.Char('Channel Service Username') passwd = fields.Char('Channel Service Password') lcode = fields.Char('Channel Service lcode') diff --git a/hotel_channel_connector/models/hotel_channel_connector_ota_info.py b/hotel_channel_connector/models/hotel_channel_connector_ota_info.py index 57df21caf..3ed70d301 100644 --- a/hotel_channel_connector/models/hotel_channel_connector_ota_info.py +++ b/hotel_channel_connector/models/hotel_channel_connector_ota_info.py @@ -5,7 +5,7 @@ from openerp import models, fields, api from odoo.addons.queue_job.job import job class HotelChannelConnectorOTAInfo(models.Model): - _name = 'hote.channel.connector.ota.info' + _name = 'hotel.channel.connector.ota.info' ota_id = fields.Char("Channel OTA ID", required=True) name = fields.Char("OTA Name", required=True) diff --git a/hotel_channel_connector/models/hotel_reservation/common.py b/hotel_channel_connector/models/hotel_reservation/common.py index 0cb085a7c..f77f0dee5 100644 --- a/hotel_channel_connector/models/hotel_reservation/common.py +++ b/hotel_channel_connector/models/hotel_reservation/common.py @@ -12,7 +12,8 @@ from odoo.addons.hotel_channel_connector.components.backend_adapter import ( WUBOOK_STATUS_REFUSED, WUBOOK_STATUS_ACCEPTED, WUBOOK_STATUS_CANCELLED, - WUBOOK_STATUS_CANCELLED_PENALTY) + WUBOOK_STATUS_CANCELLED_PENALTY, + WUBOOK_STATUS_BAD) class ChannelHotelReservation(models.Model): _name = 'channel.hotel.reservation' @@ -20,7 +21,7 @@ class ChannelHotelReservation(models.Model): _inherits = {'hotel.reservation': 'odoo_id'} _description = 'Channel Hotel Reservation' - odoo_id = fields.Many2one(comodel_names='hotel.reservation', + odoo_id = fields.Many2one(comodel_name='hotel.reservation', string='Reservation', required=True, ondelete='cascade') @@ -88,6 +89,23 @@ class HotelReservation(models.Model): user = self.env['res.users'].browse(self.env.uid) record.able_to_modify_channel = user.has_group('base.group_system') + @api.depends('channel_type', 'channel_bind_ids.ota_id') + def _get_origin_sale(self): + for record in self: + if not record.channel_type: + record.channel_type = 'door' + record.origin_sale = dict( + self.fields_get( + allfields=['channel_type'])['channel_type']['selection'])[record.channel_type] \ + if record.channel_type != 'web' or not record.channel_bind_ids[0].ota_id \ + else record.channel_bind_ids[0].ota_id.name + + channel_bind_ids = fields.One2many( + comodel_name='channel.hotel.reservation', + inverse_name='odoo_id', + string='Hotel Channel Connector Bindings') + origin_sale = fields.Char('Origin', compute=_get_origin_sale, + store=True) is_from_ota = fields.Boolean('Is From OTA', readonly=True, old_name='wis_from_channel') @@ -98,24 +116,6 @@ class HotelReservation(models.Model): customer_notes = fields.Text(related='folio_id.customer_notes', old_name='wcustomer_notes') - @api.depends('channel_type', 'ota_id') - def _get_origin_sale(self): - for record in self: - if not record.channel_type: - record.channel_type = 'door' - record.origin_sale = dict( - self.fields_get( - allfields=['channel_type'])['channel_type']['selection'])[record.channel_type] \ - if record.channel_type != 'web' or not record.ota_id \ - else record.ota_id.name - - channel_bind_ids = fields.One2many( - comodel_name='channel.hotel.reservation', - inverse_name='odoo_id', - string='Hotel Channel Connector Bindings') - origin_sale = fields.Char('Origin', compute=_get_origin_sale, - store=True) - @api.model def create(self, vals): if vals.get('channel_reservation_id') != None: @@ -203,11 +203,11 @@ class HotelReservation(models.Model): res = super(HotelReservation, self).action_cancel() if waction: - partner_id = self.env['res.users'].browse(self.env.uid).partner_id for record in self: # Only can cancel reservations created directly in wubook - if record.channel_reservation_id and not record.ota_id and \ - record.wstatus in ['1', '2', '4']: + if record.channel_bind_ids[0].channel_reservation_id and \ + not record.channel_bind_ids[0].ota_id and \ + record.channel_bind_ids[0].wstatus in ['1', '2', '4']: self._event('on_record_cancel').notify(record) return res diff --git a/hotel_channel_connector/models/hotel_room_type/common.py b/hotel_channel_connector/models/hotel_room_type/common.py index 25f08f818..b967543cb 100644 --- a/hotel_channel_connector/models/hotel_room_type/common.py +++ b/hotel_channel_connector/models/hotel_room_type/common.py @@ -13,7 +13,7 @@ class ChannelHotelRoomType(models.Model): _inherits = {'hotel.room.type': 'odoo_id'} _description = 'Channel Hotel Room' - odoo_id = fields.Many2one(comodel_names='hotel.room.type', + odoo_id = fields.Many2one(comodel_name='hotel.room.type', string='Room Type', required=True, ondelete='cascade') diff --git a/hotel_channel_connector/models/hotel_room_type_availability/common.py b/hotel_channel_connector/models/hotel_room_type_availability/common.py index 1d1dd7e7a..0f78f6ae2 100644 --- a/hotel_channel_connector/models/hotel_room_type_availability/common.py +++ b/hotel_channel_connector/models/hotel_room_type_availability/common.py @@ -23,7 +23,7 @@ class ChannelHotelRoomTypeAvailability(models.Model): return self.odoo_id.room_type_id.total_rooms_count return -1 - odoo_id = fields.Many2one(comodel_names='product.pricelist', + odoo_id = fields.Many2one(comodel_name='hotel.room.type.availability', string='Pricelist', required=True, ondelete='cascade') diff --git a/hotel_channel_connector/models/hotel_room_type_restriction/common.py b/hotel_channel_connector/models/hotel_room_type_restriction/common.py index 365c35bbc..189523a1d 100644 --- a/hotel_channel_connector/models/hotel_room_type_restriction/common.py +++ b/hotel_channel_connector/models/hotel_room_type_restriction/common.py @@ -13,7 +13,7 @@ class ChannelHotelRoomTypeRestriction(models.Model): _inherits = {'hotel.room.type.restriction': 'odoo_id'} _description = 'Channel Hotel Room Type Restriction' - odoo_id = fields.Many2one(comodel_names='hotel.room.type.restriction', + odoo_id = fields.Many2one(comodel_name='hotel.room.type.restriction', string='Hotel Virtual Room Restriction', required=True, ondelete='cascade') diff --git a/hotel_channel_connector/models/product_pricelist/common.py b/hotel_channel_connector/models/product_pricelist/common.py index a0cf0735b..976e0b338 100644 --- a/hotel_channel_connector/models/product_pricelist/common.py +++ b/hotel_channel_connector/models/product_pricelist/common.py @@ -13,7 +13,7 @@ class ChannelProductPricelist(models.Model): _inherits = {'product.pricelist': 'odoo_id'} _description = 'Channel Product Pricelist' - odoo_id = fields.Many2one(comodel_names='product.pricelist', + odoo_id = fields.Many2one(comodel_name='product.pricelist', string='Pricelist', required=True, ondelete='cascade') diff --git a/hotel_channel_connector/views/channel_hotel_reservation_views.xml b/hotel_channel_connector/views/channel_hotel_reservation_views.xml index 75073d21a..f75d53daa 100644 --- a/hotel_channel_connector/views/channel_hotel_reservation_views.xml +++ b/hotel_channel_connector/views/channel_hotel_reservation_views.xml @@ -8,7 +8,7 @@
- + diff --git a/hotel_channel_connector/views/channel_hotel_virtual_room_availability_views.xml b/hotel_channel_connector/views/channel_hotel_room_type_availability_views.xml similarity index 92% rename from hotel_channel_connector/views/channel_hotel_virtual_room_availability_views.xml rename to hotel_channel_connector/views/channel_hotel_room_type_availability_views.xml index 13549fc11..d55fa121f 100644 --- a/hotel_channel_connector/views/channel_hotel_virtual_room_availability_views.xml +++ b/hotel_channel_connector/views/channel_hotel_room_type_availability_views.xml @@ -16,7 +16,7 @@ channel.hotel.room.type.availability.tree - channel.hotel.virtual.availability.room + channel.hotel.room.type.availability diff --git a/hotel_channel_connector/views/channel_hotel_virtual_room_restriction_views.xml b/hotel_channel_connector/views/channel_hotel_room_type_restriction_views.xml similarity index 92% rename from hotel_channel_connector/views/channel_hotel_virtual_room_restriction_views.xml rename to hotel_channel_connector/views/channel_hotel_room_type_restriction_views.xml index fb34401e0..662cc317c 100644 --- a/hotel_channel_connector/views/channel_hotel_virtual_room_restriction_views.xml +++ b/hotel_channel_connector/views/channel_hotel_room_type_restriction_views.xml @@ -16,7 +16,7 @@ channel.hotel.room.type.restriction.tree - channel.hotel.virtual.restriction.room + channel.hotel.room.type.restriction diff --git a/hotel_channel_connector/views/channel_product_pricelist_views.xml b/hotel_channel_connector/views/channel_product_pricelist_views.xml index 60b2d52d8..1e64681d2 100644 --- a/hotel_channel_connector/views/channel_product_pricelist_views.xml +++ b/hotel_channel_connector/views/channel_product_pricelist_views.xml @@ -16,7 +16,7 @@ channel.hotel.product.pricelist.tree - channel.hotel.product.pricelist.room + channel.product.pricelist diff --git a/hotel_channel_connector/views/hotel_channel_connector_issue.xml b/hotel_channel_connector/views/hotel_channel_connector_issue_views.xml similarity index 86% rename from hotel_channel_connector/views/hotel_channel_connector_issue.xml rename to hotel_channel_connector/views/hotel_channel_connector_issue_views.xml index 64b3dbf93..4638222b6 100644 --- a/hotel_channel_connector/views/hotel_channel_connector_issue.xml +++ b/hotel_channel_connector/views/hotel_channel_connector_issue_views.xml @@ -3,8 +3,8 @@ - hotel.channel.coonector.issue.form - hotel.channel.coonector.issue + hotel.channel.connector.issue.form + hotel.channel.connector.issue @@ -16,7 +16,7 @@ string="Mark as Readed" groups="hotel.group_hotel_manager" class="oe_stat_button" icon="fa-warning" - attrs="{'invisible':['|', ['section', '!=', 'reservation'], ['wid', '=', False]]}"/> + attrs="{'invisible':['|', ['section', '!=', 'reservation'], ['channel_object_id', '=', False]]}"/> @@ -37,8 +37,8 @@ - hotel.channel.coonector.issue.tree - hotel.channel.coonector.issue + hotel.channel.connector.issue.tree + hotel.channel.connector.issue tree @@ -54,8 +54,8 @@ - hotel.channel.coonector.issue.search - hotel.channel.coonector.issue + hotel.channel.connector.issue.search + hotel.channel.connector.issue diff --git a/hotel_channel_connector/views/wubook_hotel_channel_connector_ota_info.xml b/hotel_channel_connector/views/hotel_channel_connector_ota_info_views.xml similarity index 98% rename from hotel_channel_connector/views/wubook_hotel_channel_connector_ota_info.xml rename to hotel_channel_connector/views/hotel_channel_connector_ota_info_views.xml index ab1a5aa77..07f559d22 100644 --- a/hotel_channel_connector/views/wubook_hotel_channel_connector_ota_info.xml +++ b/hotel_channel_connector/views/hotel_channel_connector_ota_info_views.xml @@ -21,7 +21,7 @@ hotel.channel.connector.ota.info.tree - hotel.channel.connector.ota.info.info + hotel.channel.connector.ota.info diff --git a/hotel_channel_connector/views/inherited_hotel_folio_views.xml b/hotel_channel_connector/views/inherited_hotel_folio_views.xml index 07c352a61..a0bc01a5d 100644 --- a/hotel_channel_connector/views/inherited_hotel_folio_views.xml +++ b/hotel_channel_connector/views/inherited_hotel_folio_views.xml @@ -21,20 +21,20 @@ - {'readonly': [('wis_from_channel', '!=', False)]} + {'readonly': [('is_from_ota', '!=', False)]} - {'readonly': [('wis_from_channel', '!=', False)]} + {'readonly': [('is_from_ota', '!=', False)]} - {'readonly': [('wis_from_channel', '!=', False)]} + {'readonly': [('is_from_ota', '!=', False)]} - {'readonly': [('wis_from_channel', '!=', False)]} + {'readonly': [('is_from_ota', '!=', False)]} diff --git a/hotel_channel_connector/views/inherited_hotel_reservation_views.xml b/hotel_channel_connector/views/inherited_hotel_reservation_views.xml index 40f0cc582..143f9247c 100644 --- a/hotel_channel_connector/views/inherited_hotel_reservation_views.xml +++ b/hotel_channel_connector/views/inherited_hotel_reservation_views.xml @@ -6,9 +6,9 @@ - + - + @@ -39,7 +39,8 @@ {'readonly': [('is_from_ota','=',True),('able_to_modify_channel','=',False)]} - {'readonly': [('channel_reservation_id','!=',False),('able_to_modify_channel','=',False)]} + + {'readonly': [('able_to_modify_channel','=',False)]} {'readonly': [('is_from_ota','=',True),('able_to_modify_channel','=',False)]} @@ -74,7 +75,7 @@ - + - + hotel.room.type.availability @@ -23,14 +23,15 @@ - - hotel.room.type.availability - - tree - - - - + + diff --git a/hotel_channel_connector/views/inherited_product_pricelist_item_views.xml b/hotel_channel_connector/views/inherited_product_pricelist_item_views.xml index 3cac71b9b..696e56773 100644 --- a/hotel_channel_connector/views/inherited_product_pricelist_item_views.xml +++ b/hotel_channel_connector/views/inherited_product_pricelist_item_views.xml @@ -6,7 +6,7 @@ - + diff --git a/hotel_channel_connector/views/inherited_product_pricelist_views.xml b/hotel_channel_connector/views/inherited_product_pricelist_views.xml index 23e320058..ab4882128 100644 --- a/hotel_channel_connector/views/inherited_product_pricelist_views.xml +++ b/hotel_channel_connector/views/inherited_product_pricelist_views.xml @@ -7,7 +7,7 @@
-
diff --git a/hotel_channel_connector/views/inherited_reservation_restriction_views.xml b/hotel_channel_connector/views/inherited_reservation_restriction_views.xml index 77bba32ad..ca93004bf 100644 --- a/hotel_channel_connector/views/inherited_reservation_restriction_views.xml +++ b/hotel_channel_connector/views/inherited_reservation_restriction_views.xml @@ -7,7 +7,7 @@
-
diff --git a/hotel_channel_connector/wizard/wubook_import_availability.xml b/hotel_channel_connector/wizard/wubook_import_availability.xml index 24f35482e..7ef14c0cf 100644 --- a/hotel_channel_connector/wizard/wubook_import_availability.xml +++ b/hotel_channel_connector/wizard/wubook_import_availability.xml @@ -15,7 +15,7 @@
- +