diff --git a/hotel_channel_connector/__init__.py b/hotel_channel_connector/__init__.py index 88bc9d53e..c541689a3 100644 --- a/hotel_channel_connector/__init__.py +++ b/hotel_channel_connector/__init__.py @@ -1,6 +1,6 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import models, fields, api, _ + from . import controllers from . import models from . import wizard diff --git a/hotel_channel_connector/__manifest__.py b/hotel_channel_connector/__manifest__.py index 54a24d869..9e905be3a 100644 --- a/hotel_channel_connector/__manifest__.py +++ b/hotel_channel_connector/__manifest__.py @@ -23,9 +23,8 @@ 'wizard/wubook_import_plan_restrictions.xml', 'wizard/wubook_import_availability.xml', 'views/general.xml', - 'views/res_config_views.xml', 'views/inherited_hotel_reservation_views.xml', - 'views/inherited_hotel_virtual_room_views.xml', + 'views/inherited_hotel_room_type_views.xml', 'views/inherited_hotel_virtual_room_availability_views.xml', 'views/inherited_hotel_folio_views.xml', 'views/inherited_product_pricelist_views.xml', @@ -35,6 +34,11 @@ 'views/inherited_res_partner_views.xml', 'views/wubook_channel_info_views.xml', 'views/wubook_issue_views.xml', + 'views/channel_hotel_reservation_views.xml', + 'views/channel_hotel_room_type_views.xml', + 'views/channel_hotel_virtual_room_availability_views.xml', + 'views/channel_hotel_virtual_room_restriction_views.xml', + 'views/channel_product_pricelist_views.xml', 'data/menus.xml', 'data/sequences.xml', 'security/ir.model.access.csv', diff --git a/hotel_channel_connector/components/__init__.py b/hotel_channel_connector/components/__init__.py index 8c217199f..31e003db2 100644 --- a/hotel_channel_connector/components/__init__.py +++ b/hotel_channel_connector/components/__init__.py @@ -1,5 +1,6 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from . import backend_adapter from . import binder from . import core diff --git a/hotel_channel_connector/components/backend_adapter.py b/hotel_channel_connector/components/backend_adapter.py index d40ee0446..054fc551c 100644 --- a/hotel_channel_connector/components/backend_adapter.py +++ b/hotel_channel_connector/components/backend_adapter.py @@ -1,3 +1,6 @@ +# Copyright 2018 Alexandre Díaz +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from odoo.addons.component.core import AbstractComponent from odoo.addons.queue_job.exception import RetryableJobError from odoo.tools import ( diff --git a/hotel_channel_connector/components/binder.py b/hotel_channel_connector/components/binder.py index 4cff79066..b64551413 100644 --- a/hotel_channel_connector/components/binder.py +++ b/hotel_channel_connector/components/binder.py @@ -1,5 +1,6 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from odoo.addons.component.core import Component class HotelConnectorModelBinder(Component): diff --git a/hotel_channel_connector/components/core.py b/hotel_channel_connector/components/core.py index 9ed977565..d47d6b2fc 100644 --- a/hotel_channel_connector/components/core.py +++ b/hotel_channel_connector/components/core.py @@ -1,3 +1,6 @@ +# Copyright 2018 Alexandre Díaz +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from odoo.addons.component.core import AbstractComponent from odoo import api diff --git a/hotel_channel_connector/components/exporter.py b/hotel_channel_connector/components/exporter.py index 3b92a7323..2abb28266 100644 --- a/hotel_channel_connector/components/exporter.py +++ b/hotel_channel_connector/components/exporter.py @@ -1,5 +1,6 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + import logging from odoo.addons.component.core import AbstractComponent from odoo.tools import ( diff --git a/hotel_channel_connector/components/importer.py b/hotel_channel_connector/components/importer.py index 4a57f0589..fb57c07e6 100644 --- a/hotel_channel_connector/components/importer.py +++ b/hotel_channel_connector/components/importer.py @@ -1,5 +1,6 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + import logging from odoo.addons.component.core import AbstractComponent from odoo.tools import ( diff --git a/hotel_channel_connector/controllers/main.py b/hotel_channel_connector/controllers/main.py index 5e06b04f1..75b9e94ae 100644 --- a/hotel_channel_connector/controllers/main.py +++ b/hotel_channel_connector/controllers/main.py @@ -1,5 +1,6 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + import logging from openerp import http, _ from openerp.http import request diff --git a/hotel_channel_connector/models/__init__.py b/hotel_channel_connector/models/__init__.py index d9ef21d71..dd404b479 100644 --- a/hotel_channel_connector/models/__init__.py +++ b/hotel_channel_connector/models/__init__.py @@ -1,7 +1,10 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import channel_backend +from . import channel_binding from . import res_config -from . import hotel_virtual_room +from . import hotel_room_type from . import product_pricelist from . import inherited_product_pricelist_item from . import hotel_virtual_room_restriction @@ -10,5 +13,5 @@ from . import hotel_virtual_room_availability from . import hotel_reservation from . import inherited_hotel_folio from . import inherited_res_partner -from . import wubook_channel_info +from . import hotel_channel_connector_ota_info from . import hotel_channel_connector_issue diff --git a/hotel_channel_connector/models/channel_backend/__init__.py b/hotel_channel_connector/models/channel_backend/__init__.py index c3d0f6b2b..257ab04fc 100644 --- a/hotel_channel_connector/models/channel_backend/__init__.py +++ b/hotel_channel_connector/models/channel_backend/__init__.py @@ -1,3 +1,4 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from . import common diff --git a/hotel_channel_connector/models/channel_backend/common.py b/hotel_channel_connector/models/channel_backend/common.py index a8ebce94f..1307e5572 100644 --- a/hotel_channel_connector/models/channel_backend/common.py +++ b/hotel_channel_connector/models/channel_backend/common.py @@ -1,11 +1,22 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from contextlib import contextmanager +from odoo import models, api, fields +from ...components.backend_adapter import WuBookLogin, WuBookAdapter + class ChannelBackend(models.Model): _name = 'channel.backend' _description = 'Hotel Channel Backend' _inherit = 'connector.backend' + username = fields.Char('Channel Service Username') + passwd = fields.Char('Channel Service Password') + lcode = fields.Char('Channel Service lcode') + server = fields.Char('Channel Service Server', + default='https://wired.wubook.net/xrws/') + pkey = fields.Char('Channel Service PKey') + @contextmanager @api.multi def work_on(self, model_name, **kwargs): @@ -13,23 +24,12 @@ class ChannelBackend(models.Model): lang = self.default_lang_id if lang.code != self.env.context.get('lang'): self = self.with_context(lang=lang.code) - user = self.env['ir.default'].sudo().get( - 'res.config.settings', 'hotel_connector_user') - passwd = self.env['ir.default'].sudo().get( - 'res.config.settings', 'hotel_connector_passwd') - lcode = self.env['ir.default'].sudo().get( - 'res.config.settings', 'hotel_connector_lcode') - pkey = self.env['ir.default'].sudo().get( - 'res.config.settings', 'hotel_connector_pkey') - server_addr = self.env['ir.default'].sudo().get( - 'res.config.settings', 'hotel_connector_server') wubook_login = WuBookLogin( - server_addr, - user, - passwd, - lcode, - pkey - ) + self.server, + self.username, + self.passwd, + self.lcode, + self.pkey) with WuBookAdapter(wubook_login) as channel_api: _super = super(ChannelBackend, self) # from the components we'll be able to do: self.work.magento_api diff --git a/hotel_channel_connector/models/channel_binding/__init__.py b/hotel_channel_connector/models/channel_binding/__init__.py index c3d0f6b2b..257ab04fc 100644 --- a/hotel_channel_connector/models/channel_binding/__init__.py +++ b/hotel_channel_connector/models/channel_binding/__init__.py @@ -1,3 +1,4 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from . import common diff --git a/hotel_channel_connector/models/channel_binding/common.py b/hotel_channel_connector/models/channel_binding/common.py index 23a7015c8..d7ccb7a88 100644 --- a/hotel_channel_connector/models/channel_binding/common.py +++ b/hotel_channel_connector/models/channel_binding/common.py @@ -1,8 +1,7 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, models, fields -from odoo.addons.queue_job.job import job, related_action +from odoo import models, fields class ChannelBinding(models.AbstractModel): diff --git a/hotel_channel_connector/models/hotel_channel_connector_issue.py b/hotel_channel_connector/models/hotel_channel_connector_issue.py index 293bc7636..5e77127c7 100644 --- a/hotel_channel_connector/models/hotel_channel_connector_issue.py +++ b/hotel_channel_connector/models/hotel_channel_connector_issue.py @@ -1,5 +1,6 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from openerp import models, fields, api, _ from openerp.exceptions import ValidationError 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 0f5312ca4..57df21caf 100644 --- a/hotel_channel_connector/models/hotel_channel_connector_ota_info.py +++ b/hotel_channel_connector/models/hotel_channel_connector_ota_info.py @@ -1,7 +1,8 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import models, fields, api +from openerp import models, fields, api +from odoo.addons.queue_job.job import job class HotelChannelConnectorOTAInfo(models.Model): _name = 'hote.channel.connector.ota.info' diff --git a/hotel_channel_connector/models/hotel_reservation/__init__.py b/hotel_channel_connector/models/hotel_reservation/__init__.py index c3d0f6b2b..257ab04fc 100644 --- a/hotel_channel_connector/models/hotel_reservation/__init__.py +++ b/hotel_channel_connector/models/hotel_reservation/__init__.py @@ -1,3 +1,4 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from . import common diff --git a/hotel_channel_connector/models/hotel_reservation/common.py b/hotel_channel_connector/models/hotel_reservation/common.py index 0804cdf64..f075590cb 100644 --- a/hotel_channel_connector/models/hotel_reservation/common.py +++ b/hotel_channel_connector/models/hotel_reservation/common.py @@ -3,6 +3,15 @@ from odoo import api, models, fields from odoo.addons.queue_job.job import job, related_action +from odoo.addons.component.core import Component +from odoo.addons.component_event import skip_if +from odoo.addons.hotel_channel_connector.components.backend_adapter import ( + WUBOOK_STATUS_CONFIRMED, + WUBOOK_STATUS_WAITING, + WUBOOK_STATUS_REFUSED, + WUBOOK_STATUS_ACCEPTED, + WUBOOK_STATUS_CANCELLED, + WUBOOK_STATUS_CANCELLED_PENALTY) class ChannelHotelReservation(models.Model): _name = 'channel.hotel.reservation' @@ -10,11 +19,6 @@ class ChannelHotelReservation(models.Model): _inherits = {'hotel.reservation': 'odoo_id'} _description = 'Channel Hotel Reservation' - @api.depends('channel_reservation_id', 'ota_id') - def _is_from_ota(self): - for record in self: - record.is_from_ota = (record.channel_reservation_id and record.ota_id) - odoo_id = fields.Many2one(comodel_names='hotel.reservation', string='Reservation', required=True, @@ -27,25 +31,18 @@ class ChannelHotelReservation(models.Model): ota_reservation_id = fields.Char("Channel OTA Reservation Code", readonly=True, old_name='wchannel_reservation_code') - is_from_ota = fields.Boolean('Is From OTA', - compute=_is_from_ota, store=False, - readonly=True, - old_name='wis_from_channel') - to_read = fields.Boolean('To Read', default=False) - able_to_modify_channel = fields.Boolean(compute=set_access_for_wubook_fields, - string='Is user able to modify wubook fields?', - old_name='able_to_modify_wubook') channel_raw_data = fields.Text(readonly=True, old_name='wbook_json') wstatus = fields.Selection([ - ('0', 'No WuBook'), + ('0', 'No Channel'), (str(WUBOOK_STATUS_CONFIRMED), 'Confirmed'), (str(WUBOOK_STATUS_WAITING), 'Waiting'), (str(WUBOOK_STATUS_REFUSED), 'Refused'), (str(WUBOOK_STATUS_ACCEPTED), 'Accepted'), (str(WUBOOK_STATUS_CANCELLED), 'Cancelled'), (str(WUBOOK_STATUS_CANCELLED_PENALTY), 'Cancelled with penalty')], - string='WuBook Status', default='0', + string='WuBook Status', + default='0', readonly=True) wstatus_reason = fields.Char("WuBook Status Reason", readonly=True) customer_notes = fields.Text(related='folio_id.customer_notes', @@ -68,23 +65,39 @@ class ChannelHotelReservation(models.Model): def cancel_reservation(self): self.ensure_one() if self._context.get('channel_action', True): + user = self.env['res.user'].browse(self.env.uid) with self.backend_id.work_on(self._name) as work: adapter = work.component(usage='backend.adapter') wres = adapter.cancel_reservation( self.channel_reservation_id, - _('Cancelled by %s') % partner_id.name) + _('Cancelled by %s') % user.partner_id.name) if not wres: raise ValidationError(_("Can't cancel reservation on WuBook")) class HotelReservation(models.Model): _inherit = 'hotel.reservation' + @api.depends('channel_bind_ids.channel_reservation_id', 'channel_bind_ids.ota_id') + def _is_from_ota(self): + for record in self: + record.is_from_ota = (record.channel_bind_ids.channel_reservation_id and \ + record.channel_bind_ids.ota_id) + @api.multi - def set_access_for_wubook_fields(self): + def _set_access_for_wubook_fields(self): for rec in self: user = self.env['res.users'].browse(self.env.uid) rec.able_to_modify_channel = user.has_group('base.group_system') + is_from_ota = fields.Boolean('Is From OTA', + compute=_is_from_ota, store=False, + readonly=True, + old_name='wis_from_channel') + able_to_modify_channel = fields.Boolean(compute=_set_access_for_wubook_fields, + string='Is user able to modify wubook fields?', + old_name='able_to_modify_wubook') + to_read = fields.Boolean('To Read', default=False) + @api.depends('channel_type', 'ota_id') def _get_origin_sale(self): for record in self: @@ -211,30 +224,27 @@ class HotelReservation(models.Model): raise ValidationError(_("Can't confirm OTA's cancelled reservations")) return super(HotelReservation, self).confirm() - @api.multi - def generate_copy_values(self, checkin=False, checkout=False): - self.ensure_one() - res = super().generate_copy_values(checkin=checkin, checkout=checkout) - res.update({ - 'channel_reservation_id': self.channel_reservation_id, - 'ota_id': self.ota_id and self.ota_id.id or False, - 'ota_reservation_code': self.ota_reservation_code, - 'is_from_ota': self.is_from_ota, - 'to_read': self.to_read, - 'wstatus': self.wstatus, - 'wstatus_reason': self.wstatus_reason, - 'customer_notes': self.customer_notes, - }) - return res + # @api.multi + # def generate_copy_values(self, checkin=False, checkout=False): + # self.ensure_one() + # res = super().generate_copy_values(checkin=checkin, checkout=checkout) + # res.update({ + # 'channel_reservation_id': self.channel_reservation_id, + # 'ota_id': self.ota_id and self.ota_id.id or False, + # 'ota_reservation_code': self.ota_reservation_code, + # 'is_from_ota': self.is_from_ota, + # 'to_read': self.to_read, + # 'wstatus': self.wstatus, + # 'wstatus_reason': self.wstatus_reason, + # 'customer_notes': self.customer_notes, + # }) + # return res @api.multi def action_reservation_checkout(self): for record in self: - if record.state == 'cancelled': - return - else: - return super(HotelReservation, record).\ - action_reservation_checkout() + if record.state != 'cancelled': + return super(HotelReservation, record).action_reservation_checkout() @api.model def _hcalendar_reservation_data(self, reservations): diff --git a/hotel_channel_connector/models/hotel_virtual_room/__init__.py b/hotel_channel_connector/models/hotel_room_type/__init__.py similarity index 99% rename from hotel_channel_connector/models/hotel_virtual_room/__init__.py rename to hotel_channel_connector/models/hotel_room_type/__init__.py index c3d0f6b2b..257ab04fc 100644 --- a/hotel_channel_connector/models/hotel_virtual_room/__init__.py +++ b/hotel_channel_connector/models/hotel_room_type/__init__.py @@ -1,3 +1,4 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from . import common diff --git a/hotel_channel_connector/models/hotel_virtual_room/common.py b/hotel_channel_connector/models/hotel_room_type/common.py similarity index 89% rename from hotel_channel_connector/models/hotel_virtual_room/common.py rename to hotel_channel_connector/models/hotel_room_type/common.py index 1835fb387..af3226565 100644 --- a/hotel_channel_connector/models/hotel_virtual_room/common.py +++ b/hotel_channel_connector/models/hotel_room_type/common.py @@ -3,12 +3,14 @@ from odoo import api, models, fields from odoo.addons.queue_job.job import job, related_action +from odoo.addons.component.core import Component +from odoo.addons.component_event import skip_if -class ChannelHotelVirtualRoom(models.Model): - _name = 'channel.hotel.virtual.room' +class ChannelHotelRoomType(models.Model): + _name = 'channel.hotel.room.type' _inherit = 'channel.binding' - _inherits = {'hotel.virtual.room': 'odoo_id'} - _description = 'Channel Hotel Virtual Room' + _inherits = {'hotel.room.type': 'odoo_id'} + _description = 'Channel Hotel Room' @api.depends('ota_capacity') @api.onchange('room_ids', 'room_type_ids') @@ -16,8 +18,8 @@ class ChannelHotelVirtualRoom(models.Model): for rec in self: rec.ota_capacity = rec.get_capacity() - odoo_id = fields.Many2one(comodel_names='hotel.virtual.room', - string='Reservation', + odoo_id = fields.Many2one(comodel_names='hotel.room.type', + string='Room Type', required=True, ondelete='cascade') channel_room_id = fields.Char("Channel Room ID", readonly=True, old_name='wrid') @@ -102,11 +104,11 @@ class ChannelHotelVirtualRoom(models.Model): importer = work.component(usage='channel.importer') return importer.import_rooms() -class HotelVirtualRoom(models.Model): - _inherit = 'hotel.virtual.room' +class HotelRoomType(models.Model): + _inherit = 'hotel.room.type' channel_bind_ids = fields.One2many( - comodel_name='channel.hotel.virtual.room', + comodel_name='channel.hotel.room.type', inverse_name='odoo_id', string='Hotel Channel Connector Bindings') @@ -124,10 +126,10 @@ class HotelVirtualRoom(models.Model): ], limit=1) return restriction -class ChannelBindingVirtualRoomListener(Component): - _name = 'channel.binding.virtual.room.listener' +class ChannelBindingRoomTypeListener(Component): + _name = 'channel.binding.room.type.listener' _inherit = 'base.connector.listener' - _apply_on = ['channel.virtual.room'] + _apply_on = ['channel.room.type'] @skip_if(lambda self, record, **kwargs: self.no_connector_export(record)) def on_record_write(self, record, fields=None): diff --git a/hotel_channel_connector/models/hotel_virtual_room_availability/__init__.py b/hotel_channel_connector/models/hotel_virtual_room_availability/__init__.py index c3d0f6b2b..257ab04fc 100644 --- a/hotel_channel_connector/models/hotel_virtual_room_availability/__init__.py +++ b/hotel_channel_connector/models/hotel_virtual_room_availability/__init__.py @@ -1,3 +1,4 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from . import common diff --git a/hotel_channel_connector/models/hotel_virtual_room_availability/common.py b/hotel_channel_connector/models/hotel_virtual_room_availability/common.py index df322237c..0ec8e6a8f 100644 --- a/hotel_channel_connector/models/hotel_virtual_room_availability/common.py +++ b/hotel_channel_connector/models/hotel_virtual_room_availability/common.py @@ -3,6 +3,8 @@ from odoo import api, models, fields from odoo.addons.queue_job.job import job, related_action +from odoo.addons.component.core import Component +from odoo.addons.component_event import skip_if class ChannelHotelVirtualRoomAvailability(models.Model): _name = 'channel.hotel.virtual.room.availability' diff --git a/hotel_channel_connector/models/hotel_virtual_room_restriction/__init__.py b/hotel_channel_connector/models/hotel_virtual_room_restriction/__init__.py index c3d0f6b2b..257ab04fc 100644 --- a/hotel_channel_connector/models/hotel_virtual_room_restriction/__init__.py +++ b/hotel_channel_connector/models/hotel_virtual_room_restriction/__init__.py @@ -1,3 +1,4 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from . import common diff --git a/hotel_channel_connector/models/hotel_virtual_room_restriction/common.py b/hotel_channel_connector/models/hotel_virtual_room_restriction/common.py index 67a73d978..e1ccda674 100644 --- a/hotel_channel_connector/models/hotel_virtual_room_restriction/common.py +++ b/hotel_channel_connector/models/hotel_virtual_room_restriction/common.py @@ -3,6 +3,8 @@ from odoo import api, models, fields from odoo.addons.queue_job.job import job, related_action +from odoo.addons.component.core import Component +from odoo.addons.component_event import skip_if class ChannelHotelVirtualRoomRestriction(models.Model): _name = 'channel.hotel.virtual.room.restriction' diff --git a/hotel_channel_connector/models/inherited_hotel_folio.py b/hotel_channel_connector/models/inherited_hotel_folio.py index 17637054f..5e025125a 100644 --- a/hotel_channel_connector/models/inherited_hotel_folio.py +++ b/hotel_channel_connector/models/inherited_hotel_folio.py @@ -1,6 +1,8 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from openerp import models, fields, api +from odoo.addons.queue_job.job import job class HotelFolio(models.Model): diff --git a/hotel_channel_connector/models/inherited_product_pricelist_item.py b/hotel_channel_connector/models/inherited_product_pricelist_item.py index b61bd059c..4a3faee7b 100644 --- a/hotel_channel_connector/models/inherited_product_pricelist_item.py +++ b/hotel_channel_connector/models/inherited_product_pricelist_item.py @@ -1,5 +1,6 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from openerp import models, fields, api from openerp.exceptions import ValidationError diff --git a/hotel_channel_connector/models/inherited_res_partner.py b/hotel_channel_connector/models/inherited_res_partner.py index a396d3b4a..483a7ee05 100644 --- a/hotel_channel_connector/models/inherited_res_partner.py +++ b/hotel_channel_connector/models/inherited_res_partner.py @@ -1,5 +1,6 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from openerp import models, fields, api diff --git a/hotel_channel_connector/models/inherited_reservation_restriction_item.py b/hotel_channel_connector/models/inherited_reservation_restriction_item.py index 181738612..628e9de88 100644 --- a/hotel_channel_connector/models/inherited_reservation_restriction_item.py +++ b/hotel_channel_connector/models/inherited_reservation_restriction_item.py @@ -1,5 +1,6 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from openerp import models, fields, api diff --git a/hotel_channel_connector/models/product_pricelist/__init__.py b/hotel_channel_connector/models/product_pricelist/__init__.py index c3d0f6b2b..257ab04fc 100644 --- a/hotel_channel_connector/models/product_pricelist/__init__.py +++ b/hotel_channel_connector/models/product_pricelist/__init__.py @@ -1,3 +1,4 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from . import common diff --git a/hotel_channel_connector/models/product_pricelist/common.py b/hotel_channel_connector/models/product_pricelist/common.py index b07f9800b..98af35d65 100644 --- a/hotel_channel_connector/models/product_pricelist/common.py +++ b/hotel_channel_connector/models/product_pricelist/common.py @@ -3,6 +3,8 @@ from odoo import api, models, fields from odoo.addons.queue_job.job import job, related_action +from odoo.addons.component.core import Component +from odoo.addons.component_event import skip_if class ChannelProductPricelist(models.Model): _name = 'channel.product.pricelist' diff --git a/hotel_channel_connector/models/res_config.py b/hotel_channel_connector/models/res_config.py index 0478a8e86..28e5a8122 100644 --- a/hotel_channel_connector/models/res_config.py +++ b/hotel_channel_connector/models/res_config.py @@ -1,5 +1,6 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + import os import binascii import logging @@ -10,49 +11,30 @@ from odoo.addons.hotel import date_utils _logger = logging.getLogger(__name__) -class WubookConfiguration(models.TransientModel): - _name = 'wubook.config.settings' +class HotelChannelConnectorConfiguration(models.TransientModel): _inherit = 'res.config.settings' - wubook_user = fields.Char('WuBook User') - wubook_passwd = fields.Char('WuBook Password') - wubook_lcode = fields.Char('WuBook lcode') - wubook_server = fields.Char('WuBook Server', - default='https://wired.wubook.net/xrws/') - wubook_pkey = fields.Char('WuBook PKey') - wubook_push_security_token = fields.Char('WuBook Push Notification \ - Security Token') + channel_push_security_token = fields.Char('WuBook Push Notification Security Token') @api.multi - def set_wubook_user(self): - return self.env['ir.default'].sudo().set( - 'wubook.config.settings', 'wubook_user', self.wubook_user) + def set_values(self): + super(HotelChannelConnectorConfiguration, self).set_values() - @api.multi - def set_wubook_passwd(self): - return self.env['ir.default'].sudo().set( - 'wubook.config.settings', 'wubook_passwd', self.wubook_passwd) + self.env['ir.default'].sudo().set( + 'res.config.settings', 'channel_push_security_token', + self.channel_push_security_token) - @api.multi - def set_wubook_lcode(self): - return self.env['ir.default'].sudo().set( - 'wubook.config.settings', 'wubook_lcode', self.wubook_lcode) + @api.model + def get_values(self): + res = super(HotelChannelConnectorConfiguration, self).get_values() - @api.multi - def set_wubook_server(self): - return self.env['ir.default'].sudo().set( - 'wubook.config.settings', 'wubook_server', self.wubook_server) - - @api.multi - def set_wubook_pkey(self): - return self.env['ir.default'].sudo().set( - 'wubook.config.settings', 'wubook_pkey', self.wubook_pkey) - - @api.multi - def set_wubook_push_security_token(self): - return self.env['ir.default'].sudo().set( - 'wubook.config.settings', - 'wubook_push_security_token', self.wubook_push_security_token) + # ONLY FOR v11. DO NOT FORWARD-PORT + channel_push_security_token = self.env['ir.default'].sudo().get( + 'res.config.settings', 'channel_push_security_token') + res.update( + channel_push_security_token=channel_push_security_token, + ) + return res # Dangerus method: Usefull for cloned instances with new wubook account @api.multi diff --git a/hotel_channel_connector/views/channel_hotel_reservation_views.xml b/hotel_channel_connector/views/channel_hotel_reservation_views.xml new file mode 100644 index 000000000..75073d21a --- /dev/null +++ b/hotel_channel_connector/views/channel_hotel_reservation_views.xml @@ -0,0 +1,30 @@ + + + + + channel.hotel.reservation.form + channel.hotel.reservation + +
+ + + + + + + +
+
+
+ + + channel.hotel.reservation.tree + channel.hotel.reservation + + + + + + + +
diff --git a/hotel_channel_connector/views/channel_hotel_room_type_views.xml b/hotel_channel_connector/views/channel_hotel_room_type_views.xml new file mode 100644 index 000000000..e3d56323f --- /dev/null +++ b/hotel_channel_connector/views/channel_hotel_room_type_views.xml @@ -0,0 +1,28 @@ + + + + + channel.hotel.virtual.room.form + channel.hotel.virtual.room + +
+ + + + + +
+
+
+ + + channel.hotel.virtual.room.tree + channel.hotel.virtual.room + + + + + + + +
diff --git a/hotel_channel_connector/views/channel_hotel_virtual_room_availability_views.xml b/hotel_channel_connector/views/channel_hotel_virtual_room_availability_views.xml new file mode 100644 index 000000000..5b1b66b91 --- /dev/null +++ b/hotel_channel_connector/views/channel_hotel_virtual_room_availability_views.xml @@ -0,0 +1,27 @@ + + + + + channel.hotel.virtual.room.availability.form + channel.hotel.virtual.room.availability + +
+ + + + +
+
+
+ + + channel.hotel.virtual.room.availability.tree + channel.hotel.virtual.availability.room + + + + + + + +
diff --git a/hotel_channel_connector/views/channel_hotel_virtual_room_restriction_views.xml b/hotel_channel_connector/views/channel_hotel_virtual_room_restriction_views.xml new file mode 100644 index 000000000..108cd0a36 --- /dev/null +++ b/hotel_channel_connector/views/channel_hotel_virtual_room_restriction_views.xml @@ -0,0 +1,27 @@ + + + + + channel.hotel.virtual.room.restriction.form + channel.hotel.virtual.room.restriction + +
+ + + + +
+
+
+ + + channel.hotel.virtual.room.restriction.tree + channel.hotel.virtual.restriction.room + + + + + + + +
diff --git a/hotel_channel_connector/views/channel_product_pricelist_views.xml b/hotel_channel_connector/views/channel_product_pricelist_views.xml new file mode 100644 index 000000000..5dcd3c715 --- /dev/null +++ b/hotel_channel_connector/views/channel_product_pricelist_views.xml @@ -0,0 +1,27 @@ + + + + + channel.product.pricelist.form + channel.product.pricelist + +
+ + + + +
+
+
+ + + channel.hotel.product.pricelist.tree + channel.hotel.product.pricelist.room + + + + + + + +
diff --git a/hotel_channel_connector/views/general.xml b/hotel_channel_connector/views/general.xml index f502c02d7..50f93b754 100644 --- a/hotel_channel_connector/views/general.xml +++ b/hotel_channel_connector/views/general.xml @@ -1,11 +1,11 @@ - - + + diff --git a/hotel_channel_connector/views/hotel_channel_connector_issue.xml b/hotel_channel_connector/views/hotel_channel_connector_issue.xml index 0281f605b..64b3dbf93 100644 --- a/hotel_channel_connector/views/hotel_channel_connector_issue.xml +++ b/hotel_channel_connector/views/hotel_channel_connector_issue.xml @@ -1,71 +1,72 @@ - - - hotel.channel.coonector.issue.form - hotel.channel.coonector.issue - -
- -
- -
- - - - - - - - - - - - -
-
-
-
+ + + hotel.channel.coonector.issue.form + hotel.channel.coonector.issue + +
+ +
+ +
+ + + + + + + + + + + + +
+
+
+
- - - hotel.channel.coonector.issue.tree - hotel.channel.coonector.issue - tree - - - - - - - - - - - + + + hotel.channel.coonector.issue.tree + hotel.channel.coonector.issue + tree + + + + + + + + + + + - - - hotel.channel.coonector.issue.search - hotel.channel.coonector.issue - - - - - - - - - - - - -
+ + + hotel.channel.coonector.issue.search + hotel.channel.coonector.issue + + + + + + + + + + + + + + diff --git a/hotel_channel_connector/views/inherited_hotel_folio_views.xml b/hotel_channel_connector/views/inherited_hotel_folio_views.xml index 1f39f8702..07c352a61 100644 --- a/hotel_channel_connector/views/inherited_hotel_folio_views.xml +++ b/hotel_channel_connector/views/inherited_hotel_folio_views.xml @@ -6,8 +6,8 @@ - - + + diff --git a/hotel_channel_connector/views/inherited_hotel_reservation_views.xml b/hotel_channel_connector/views/inherited_hotel_reservation_views.xml index faae321a5..40f0cc582 100644 --- a/hotel_channel_connector/views/inherited_hotel_reservation_views.xml +++ b/hotel_channel_connector/views/inherited_hotel_reservation_views.xml @@ -6,7 +6,7 @@ - + @@ -15,44 +15,43 @@ - - + - - - - - - - - + + + + + + + - {'readonly': [('is_from_ota','=',True),('able_to_modify_wubook','=',False)]} + {'readonly': [('is_from_ota','=',True),('able_to_modify_channel','=',False)]} - - {'readonly': [('channel_reservation_id','!=',False),('able_to_modify_wubook','=',False)]} + + {'readonly': [('channel_reservation_id','!=',False),('able_to_modify_channel','=',False)]} - {'readonly': [('is_from_ota','=',True),('able_to_modify_wubook','=',False)]} + {'readonly': [('is_from_ota','=',True),('able_to_modify_channel','=',False)]} - {'readonly': [('is_from_ota','=',True),('able_to_modify_wubook','=',False)]} + {'readonly': [('is_from_ota','=',True),('able_to_modify_channel','=',False)]} - {'readonly': [('is_from_ota','=',True),('able_to_modify_wubook','=',False)]} + {'readonly': [('is_from_ota','=',True),('able_to_modify_channel','=',False)]} - {'readonly': [('is_from_ota','=',True),('able_to_modify_wubook','=',False)]} + {'readonly': [('is_from_ota','=',True),('able_to_modify_channel','=',False)]} diff --git a/hotel_channel_connector/views/inherited_hotel_room_type_views.xml b/hotel_channel_connector/views/inherited_hotel_room_type_views.xml new file mode 100644 index 000000000..d456ae39d --- /dev/null +++ b/hotel_channel_connector/views/inherited_hotel_room_type_views.xml @@ -0,0 +1,24 @@ + + + + + hotel.room.type + + + + + + + + + + + + + + + + + + + diff --git a/hotel_channel_connector/views/inherited_hotel_virtual_room_availability_views.xml b/hotel_channel_connector/views/inherited_hotel_virtual_room_availability_views.xml index 46ada881c..652d34b08 100644 --- a/hotel_channel_connector/views/inherited_hotel_virtual_room_availability_views.xml +++ b/hotel_channel_connector/views/inherited_hotel_virtual_room_availability_views.xml @@ -6,9 +6,19 @@ hotel.virtual.room.availability - - - + + + + + + + + + + + + + @@ -18,9 +28,9 @@ tree - + diff --git a/hotel_channel_connector/views/inherited_hotel_virtual_room_views.xml b/hotel_channel_connector/views/inherited_hotel_virtual_room_views.xml deleted file mode 100644 index b87ecd4b9..000000000 --- a/hotel_channel_connector/views/inherited_hotel_virtual_room_views.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - hotel.room.type - - - - - - - - - - - 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 a37f810dc..3cac71b9b 100644 --- a/hotel_channel_connector/views/inherited_product_pricelist_item_views.xml +++ b/hotel_channel_connector/views/inherited_product_pricelist_item_views.xml @@ -2,18 +2,17 @@ - product.pricelist.item - - - - - - - - {'readonly': [('is_daily_plan', '=', True)]} - - - - + product.pricelist.item + + + + + + + + {'readonly': [('is_daily_plan', '=', True)]} + + + diff --git a/hotel_channel_connector/views/inherited_product_pricelist_views.xml b/hotel_channel_connector/views/inherited_product_pricelist_views.xml index ace159618..23e320058 100644 --- a/hotel_channel_connector/views/inherited_product_pricelist_views.xml +++ b/hotel_channel_connector/views/inherited_product_pricelist_views.xml @@ -1,30 +1,18 @@ - + product.pricelist - -
-
-
- - - - - -
-
- - - product.pricelist - - - - - + +
+
+
+ + +
diff --git a/hotel_channel_connector/views/inherited_res_partner_views.xml b/hotel_channel_connector/views/inherited_res_partner_views.xml index e61e40a31..7aa3e5a84 100644 --- a/hotel_channel_connector/views/inherited_res_partner_views.xml +++ b/hotel_channel_connector/views/inherited_res_partner_views.xml @@ -1,18 +1,16 @@ - - + - res.partner - - - - - - - - + res.partner + + + + + + + + - - +
diff --git a/hotel_channel_connector/views/inherited_reservation_restriction_item_views.xml b/hotel_channel_connector/views/inherited_reservation_restriction_item_views.xml index ec38b02ee..bf17d14e8 100644 --- a/hotel_channel_connector/views/inherited_reservation_restriction_item_views.xml +++ b/hotel_channel_connector/views/inherited_reservation_restriction_item_views.xml @@ -2,13 +2,13 @@ - hotel.virtual.room.restriction.item - - - - True - - - + hotel.virtual.room.restriction.item + + + + True + + + diff --git a/hotel_channel_connector/views/inherited_reservation_restriction_views.xml b/hotel_channel_connector/views/inherited_reservation_restriction_views.xml index a5d64ad8c..5f0f4f9dc 100644 --- a/hotel_channel_connector/views/inherited_reservation_restriction_views.xml +++ b/hotel_channel_connector/views/inherited_reservation_restriction_views.xml @@ -1,19 +1,15 @@ - + hotel.virtual.room.restriction - -
-
-
- - - - + +
+
+
diff --git a/hotel_channel_connector/views/res_config_views.xml b/hotel_channel_connector/views/res_config_views.xml deleted file mode 100644 index 3f336b368..000000000 --- a/hotel_channel_connector/views/res_config_views.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - res.config.settings.view.form.inherit.hotel.channel.connector - res.config.settings - - - - -
-

Hotel Parity

-
-
-
-
-
-
-

Hotel Default Hours

-
-
-
-
-
-
-
-
-
-
-
-
- - - - Channel Settings - res.config.settings - -
-
-
- -
- -
-
- - - - - - - - - - - -
-
-
-
-
- -