Merge branch '11.0' of https://github.com/hootel/hootel into pr_onboard_service

This commit is contained in:
Dario Lodeiros
2018-12-04 09:58:04 +01:00
16 changed files with 53 additions and 42 deletions

View File

@@ -20,17 +20,11 @@ class ChannelBackend(models.Model):
"""
return []
def _get_default_server(self):
return ''
name = fields.Char('Name')
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')
server = fields.Char('Channel Service Server',
default=_get_default_server)
pkey = fields.Char('Channel Service PKey')
server = fields.Char('Channel Service Server')
security_token = fields.Char('Channel Service Security Token')
reservation_id_str = fields.Char('Channel Reservation ID')

View File

@@ -1,7 +1,6 @@
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
from datetime import datetime
from odoo import http, _
from odoo.http import request
@@ -9,23 +8,17 @@ from odoo.exceptions import ValidationError
from odoo.addons.hotel_channel_connector_wubook.components.backend_adapter import (
DEFAULT_WUBOOK_DATE_FORMAT)
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
_logger = logging.getLogger(__name__)
class WubookPushURL(http.Controller):
# Called when created a reservation in wubook
@http.route(['/wubook/push/reservations/<string:security_token>'],
type='http', cors="*", auth="public", methods=['POST'],
website=True, csrf=True)
website=True, csrf=False)
def wubook_push_reservations(self, security_token, **kwargs):
rcode = kwargs.get('rcode')
lcode = kwargs.get('lcode')
_logger.info("====== PUSH RESERVATION")
_logger.info(rcode)
_logger.info(lcode)
_logger.info(security_token)
# Correct Input?
if not lcode or not rcode or not security_token:
raise ValidationError(_('Invalid Input Parameters!'))

View File

@@ -20,11 +20,12 @@ class ChannelBackend(models.Model):
return [('1.2', '1.2+')]
def _get_default_server(self):
super(ChannelBackend, self)._get_default_server()
return 'https://wired.wubook.net/xrws/'
lcode = fields.Char('Channel Service lcode')
pkey = fields.Char('Channel Service PKey')
server = fields.Char('Channel Service Server',
default=_get_default_server)
@contextmanager
@api.multi

View File

@@ -4,7 +4,7 @@
from odoo.addons.component.core import Component
from odoo.addons.connector.components.mapper import mapping
from odoo.addons.hotel_channel_connector.components.core import ChannelConnectorError
from odoo import api
from odoo import api, fields
from odoo.tools import (
DEFAULT_SERVER_DATE_FORMAT,
DEFAULT_SERVER_DATETIME_FORMAT)
@@ -78,3 +78,7 @@ class ChannelOtaInfoImportMapper(Component):
@mapping
def backend_id(self, record):
return {'backend_id': self.backend_record.id}
@mapping
def sync_date(self, record):
return {'sync_date': fields.Datetime.now()}

View File

@@ -119,16 +119,16 @@ class HotelReservationImporter(Component):
'reservation_lines': reservation_lines,
'price_unit': tprice,
'to_assign': True,
'wrid': rcode,
'external_id': rcode,
'ota_id': ota_id and ota_id.id,
'wchannel_reservation_code': crcode,
'ota_reservation_id': crcode,
'channel_status': str(book['status']),
'to_read': True,
'state': is_cancellation and 'cancelled' or 'draft',
'room_type_id': room_type_bind.odoo_id.id,
'splitted': split_booking,
'wbook_json': json.dumps(book),
'wmodified': book['was_modified'],
'channel_raw_data': json.dumps(book),
'channel_modified': book['was_modified'],
'product_id': room_type_bind and room_type_bind.product_id.id,
'name': room_type_bind and room_type_bind.name,
}

View File

@@ -44,7 +44,6 @@ class HotelRoomTypeExporter(Component):
channel_message=err.data['message'])
else:
binding.write({
'external_id': external_id,
'channel_short_code': short_code,
})
self.binder.bind(external_id, binding)

View File

@@ -51,5 +51,8 @@ class HotelRoomTypeAvailabilityExporter(Component):
channel_message=err.data['message'])
return False
else:
channel_room_type_avails.write({'channel_pushed': True})
channel_room_type_avails.write({
'channel_pushed': True,
'sync_date': fields.Datetime.now(),
})
return True

View File

@@ -101,3 +101,7 @@ class HotelRoomTypeAvailabilityImportMapper(Component):
@mapping
def room_type_id(self, record):
return {'room_type_id': record['room_type_id']}
@mapping
def sync_date(self, record):
return {'sync_date': fields.Datetime.now()}

View File

@@ -31,5 +31,4 @@ class HotelRoomTypeRestrictionExporter(Component):
internal_message=str(err),
channel_message=err.data['message'])
else:
binding.external_id = external_id
self.binder.bind(external_id, binding)

View File

@@ -31,13 +31,14 @@ class HotelRoomTypeRestrictionImporter(Component):
('external_id', '=', str(plan['id'])),
], limit=1)
if not plan_bind:
channel_restriction_obj.with_context({
plan_bind = channel_restriction_obj.with_context({
'connector_no_export': True,
'rules': plan.get('rules'),
}).create(plan_record.values(for_create=True))
else:
plan_bind.with_context({'connector_no_export':True}).write(
plan_record.values())
self.binder(str(plan['id']), plan_bind)
count = count + 1
return count

View File

@@ -75,5 +75,8 @@ class HotelRoomTypeRestrictionItemExporter(Component):
internal_message=str(err),
channel_message=err.data['message'])
else:
unpushed.write({'channel_pushed': True})
unpushed.write({
'channel_pushed': True,
'sync_date': fields.Datetime.now(),
})
return True

View File

@@ -9,7 +9,7 @@ from odoo.addons.connector.components.mapper import mapping, only_create
from odoo.addons.hotel_channel_connector_wubook.components.backend_adapter import (
DEFAULT_WUBOOK_DATE_FORMAT)
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
from odoo import api
from odoo import api, fields
_logger = logging.getLogger(__name__)
@@ -117,3 +117,7 @@ class HotelRoomTypeRestrictionItemImportMapper(Component):
@mapping
def backend_id(self, record):
return {'backend_id': self.backend_record.id}
@mapping
def sync_date(self, record):
return {'sync_date': fields.Datetime.now()}

View File

@@ -33,13 +33,14 @@ class ProductPricelistImporter(Component):
('external_id', '=', str(plan['id'])),
], limit=1)
if not plan_bind:
channel_product_listprice_obj.with_context({
plan_bind = channel_product_listprice_obj.with_context({
'connector_no_export': True,
}).create(plan_record.values(for_create=True))
else:
channel_product_listprice_obj.with_context({
plan_bind.with_context({
'connector_no_export': True,
}).write(plan_record.values())
self.binder(str(plan['id']), plan_bind)
count = count + 1
return count

View File

@@ -72,5 +72,8 @@ class ProductPricelistItemExporter(Component):
internal_message=str(err),
channel_message=err.data['message'])
else:
channel_unpushed.write({'channel_pushed': True})
channel_unpushed.write({
'channel_pushed': True,
'sync_date': fields.Datetime.now(),
})
return True

View File

@@ -28,7 +28,6 @@ class ProductPricelistItemImporter(Component):
usage='import.mapper',
model_name='channel.product.pricelist.item')
if pricelist_bind:
_logger.info("==== PASA BIND")
channel_pricelist_item_obj = self.env['channel.product.pricelist.item']
dfrom_dt = fields.Date.from_string(date_from)
dto_dt = fields.Date.from_string(date_to)
@@ -59,7 +58,6 @@ class ProductPricelistItemImporter(Component):
('product_tmpl_id', '=',
channel_room_type.product_id.product_tmpl_id.id)
], limit=1)
_logger.info("=== ESCRIBEINDO")
if pricelist_item:
pricelist_item.with_context({
'connector_no_export': True,
@@ -139,3 +137,7 @@ class ProductPricelistItemImportMapper(Component):
@mapping
def backend_id(self, record):
return {'backend_id': self.backend_record.id}
@mapping
def sync_date(self, record):
return {'sync_date': fields.Datetime.now()}

View File

@@ -10,16 +10,6 @@ class HotelRoomType(models.Model):
_inherit = 'hotel.room.type'
@api.model
def check_availability_room_ids(self, dfrom, dto,
room_type_id=False, notthis=[]):
"""
Check availability for all or specific room types between dates
@return: A list of `ids` with free rooms
"""
free_rooms = super().check_availability_room_type(dfrom, dto, room_type_id, notthis)
return free_rooms.ids
@api.model
def get_room_type_availability(self, dfrom, dto, room_type_id):
free_rooms = self.check_availability_room_type(dfrom, dto)
@@ -62,3 +52,13 @@ class HotelRoomType(models.Model):
min_stay = max([r['min_stay'] for r in restrictions_plan])
return min_stay
@api.model
def get_room_type_planning(self, dfrom, dto, room_type_id):
availability = self.get_room_type_availability(dfrom, dto, room_type_id)
price_unit = self.get_room_type_price_unit(dfrom, dto, room_type_id)
restrictions = self.get_room_type_restrictions(dfrom, dto, room_type_id)
return {'availability': availability, 'price_unit': price_unit, 'restrictions': restrictions}