mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
Merge branch '11.0' of https://github.com/hootel/hootel into pr_onboard_service
This commit is contained in:
@@ -20,17 +20,11 @@ class ChannelBackend(models.Model):
|
|||||||
"""
|
"""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def _get_default_server(self):
|
|
||||||
return ''
|
|
||||||
|
|
||||||
name = fields.Char('Name')
|
name = fields.Char('Name')
|
||||||
version = fields.Selection(selection='select_versions', required=True)
|
version = fields.Selection(selection='select_versions', required=True)
|
||||||
username = fields.Char('Channel Service Username')
|
username = fields.Char('Channel Service Username')
|
||||||
passwd = fields.Char('Channel Service Password')
|
passwd = fields.Char('Channel Service Password')
|
||||||
lcode = fields.Char('Channel Service lcode')
|
server = fields.Char('Channel Service Server')
|
||||||
server = fields.Char('Channel Service Server',
|
|
||||||
default=_get_default_server)
|
|
||||||
pkey = fields.Char('Channel Service PKey')
|
|
||||||
security_token = fields.Char('Channel Service Security Token')
|
security_token = fields.Char('Channel Service Security Token')
|
||||||
|
|
||||||
reservation_id_str = fields.Char('Channel Reservation ID')
|
reservation_id_str = fields.Char('Channel Reservation ID')
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
import logging
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from odoo import http, _
|
from odoo import http, _
|
||||||
from odoo.http import request
|
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 (
|
from odoo.addons.hotel_channel_connector_wubook.components.backend_adapter import (
|
||||||
DEFAULT_WUBOOK_DATE_FORMAT)
|
DEFAULT_WUBOOK_DATE_FORMAT)
|
||||||
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
|
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||||
_logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class WubookPushURL(http.Controller):
|
class WubookPushURL(http.Controller):
|
||||||
# Called when created a reservation in wubook
|
# Called when created a reservation in wubook
|
||||||
@http.route(['/wubook/push/reservations/<string:security_token>'],
|
@http.route(['/wubook/push/reservations/<string:security_token>'],
|
||||||
type='http', cors="*", auth="public", methods=['POST'],
|
type='http', cors="*", auth="public", methods=['POST'],
|
||||||
website=True, csrf=True)
|
website=True, csrf=False)
|
||||||
def wubook_push_reservations(self, security_token, **kwargs):
|
def wubook_push_reservations(self, security_token, **kwargs):
|
||||||
rcode = kwargs.get('rcode')
|
rcode = kwargs.get('rcode')
|
||||||
lcode = kwargs.get('lcode')
|
lcode = kwargs.get('lcode')
|
||||||
|
|
||||||
_logger.info("====== PUSH RESERVATION")
|
|
||||||
_logger.info(rcode)
|
|
||||||
_logger.info(lcode)
|
|
||||||
_logger.info(security_token)
|
|
||||||
|
|
||||||
# Correct Input?
|
# Correct Input?
|
||||||
if not lcode or not rcode or not security_token:
|
if not lcode or not rcode or not security_token:
|
||||||
raise ValidationError(_('Invalid Input Parameters!'))
|
raise ValidationError(_('Invalid Input Parameters!'))
|
||||||
|
|||||||
@@ -20,11 +20,12 @@ class ChannelBackend(models.Model):
|
|||||||
return [('1.2', '1.2+')]
|
return [('1.2', '1.2+')]
|
||||||
|
|
||||||
def _get_default_server(self):
|
def _get_default_server(self):
|
||||||
super(ChannelBackend, self)._get_default_server()
|
|
||||||
return 'https://wired.wubook.net/xrws/'
|
return 'https://wired.wubook.net/xrws/'
|
||||||
|
|
||||||
lcode = fields.Char('Channel Service lcode')
|
lcode = fields.Char('Channel Service lcode')
|
||||||
pkey = fields.Char('Channel Service PKey')
|
pkey = fields.Char('Channel Service PKey')
|
||||||
|
server = fields.Char('Channel Service Server',
|
||||||
|
default=_get_default_server)
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
@api.multi
|
@api.multi
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
from odoo.addons.component.core import Component
|
from odoo.addons.component.core import Component
|
||||||
from odoo.addons.connector.components.mapper import mapping
|
from odoo.addons.connector.components.mapper import mapping
|
||||||
from odoo.addons.hotel_channel_connector.components.core import ChannelConnectorError
|
from odoo.addons.hotel_channel_connector.components.core import ChannelConnectorError
|
||||||
from odoo import api
|
from odoo import api, fields
|
||||||
from odoo.tools import (
|
from odoo.tools import (
|
||||||
DEFAULT_SERVER_DATE_FORMAT,
|
DEFAULT_SERVER_DATE_FORMAT,
|
||||||
DEFAULT_SERVER_DATETIME_FORMAT)
|
DEFAULT_SERVER_DATETIME_FORMAT)
|
||||||
@@ -78,3 +78,7 @@ class ChannelOtaInfoImportMapper(Component):
|
|||||||
@mapping
|
@mapping
|
||||||
def backend_id(self, record):
|
def backend_id(self, record):
|
||||||
return {'backend_id': self.backend_record.id}
|
return {'backend_id': self.backend_record.id}
|
||||||
|
|
||||||
|
@mapping
|
||||||
|
def sync_date(self, record):
|
||||||
|
return {'sync_date': fields.Datetime.now()}
|
||||||
|
|||||||
@@ -119,16 +119,16 @@ class HotelReservationImporter(Component):
|
|||||||
'reservation_lines': reservation_lines,
|
'reservation_lines': reservation_lines,
|
||||||
'price_unit': tprice,
|
'price_unit': tprice,
|
||||||
'to_assign': True,
|
'to_assign': True,
|
||||||
'wrid': rcode,
|
'external_id': rcode,
|
||||||
'ota_id': ota_id and ota_id.id,
|
'ota_id': ota_id and ota_id.id,
|
||||||
'wchannel_reservation_code': crcode,
|
'ota_reservation_id': crcode,
|
||||||
'channel_status': str(book['status']),
|
'channel_status': str(book['status']),
|
||||||
'to_read': True,
|
'to_read': True,
|
||||||
'state': is_cancellation and 'cancelled' or 'draft',
|
'state': is_cancellation and 'cancelled' or 'draft',
|
||||||
'room_type_id': room_type_bind.odoo_id.id,
|
'room_type_id': room_type_bind.odoo_id.id,
|
||||||
'splitted': split_booking,
|
'splitted': split_booking,
|
||||||
'wbook_json': json.dumps(book),
|
'channel_raw_data': json.dumps(book),
|
||||||
'wmodified': book['was_modified'],
|
'channel_modified': book['was_modified'],
|
||||||
'product_id': room_type_bind and room_type_bind.product_id.id,
|
'product_id': room_type_bind and room_type_bind.product_id.id,
|
||||||
'name': room_type_bind and room_type_bind.name,
|
'name': room_type_bind and room_type_bind.name,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ class HotelRoomTypeExporter(Component):
|
|||||||
channel_message=err.data['message'])
|
channel_message=err.data['message'])
|
||||||
else:
|
else:
|
||||||
binding.write({
|
binding.write({
|
||||||
'external_id': external_id,
|
|
||||||
'channel_short_code': short_code,
|
'channel_short_code': short_code,
|
||||||
})
|
})
|
||||||
self.binder.bind(external_id, binding)
|
self.binder.bind(external_id, binding)
|
||||||
|
|||||||
@@ -51,5 +51,8 @@ class HotelRoomTypeAvailabilityExporter(Component):
|
|||||||
channel_message=err.data['message'])
|
channel_message=err.data['message'])
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
channel_room_type_avails.write({'channel_pushed': True})
|
channel_room_type_avails.write({
|
||||||
|
'channel_pushed': True,
|
||||||
|
'sync_date': fields.Datetime.now(),
|
||||||
|
})
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -101,3 +101,7 @@ class HotelRoomTypeAvailabilityImportMapper(Component):
|
|||||||
@mapping
|
@mapping
|
||||||
def room_type_id(self, record):
|
def room_type_id(self, record):
|
||||||
return {'room_type_id': record['room_type_id']}
|
return {'room_type_id': record['room_type_id']}
|
||||||
|
|
||||||
|
@mapping
|
||||||
|
def sync_date(self, record):
|
||||||
|
return {'sync_date': fields.Datetime.now()}
|
||||||
|
|||||||
@@ -31,5 +31,4 @@ class HotelRoomTypeRestrictionExporter(Component):
|
|||||||
internal_message=str(err),
|
internal_message=str(err),
|
||||||
channel_message=err.data['message'])
|
channel_message=err.data['message'])
|
||||||
else:
|
else:
|
||||||
binding.external_id = external_id
|
|
||||||
self.binder.bind(external_id, binding)
|
self.binder.bind(external_id, binding)
|
||||||
|
|||||||
@@ -31,13 +31,14 @@ class HotelRoomTypeRestrictionImporter(Component):
|
|||||||
('external_id', '=', str(plan['id'])),
|
('external_id', '=', str(plan['id'])),
|
||||||
], limit=1)
|
], limit=1)
|
||||||
if not plan_bind:
|
if not plan_bind:
|
||||||
channel_restriction_obj.with_context({
|
plan_bind = channel_restriction_obj.with_context({
|
||||||
'connector_no_export': True,
|
'connector_no_export': True,
|
||||||
'rules': plan.get('rules'),
|
'rules': plan.get('rules'),
|
||||||
}).create(plan_record.values(for_create=True))
|
}).create(plan_record.values(for_create=True))
|
||||||
else:
|
else:
|
||||||
plan_bind.with_context({'connector_no_export':True}).write(
|
plan_bind.with_context({'connector_no_export':True}).write(
|
||||||
plan_record.values())
|
plan_record.values())
|
||||||
|
self.binder(str(plan['id']), plan_bind)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
|||||||
@@ -75,5 +75,8 @@ class HotelRoomTypeRestrictionItemExporter(Component):
|
|||||||
internal_message=str(err),
|
internal_message=str(err),
|
||||||
channel_message=err.data['message'])
|
channel_message=err.data['message'])
|
||||||
else:
|
else:
|
||||||
unpushed.write({'channel_pushed': True})
|
unpushed.write({
|
||||||
|
'channel_pushed': True,
|
||||||
|
'sync_date': fields.Datetime.now(),
|
||||||
|
})
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -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 (
|
from odoo.addons.hotel_channel_connector_wubook.components.backend_adapter import (
|
||||||
DEFAULT_WUBOOK_DATE_FORMAT)
|
DEFAULT_WUBOOK_DATE_FORMAT)
|
||||||
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
|
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||||
from odoo import api
|
from odoo import api, fields
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@@ -117,3 +117,7 @@ class HotelRoomTypeRestrictionItemImportMapper(Component):
|
|||||||
@mapping
|
@mapping
|
||||||
def backend_id(self, record):
|
def backend_id(self, record):
|
||||||
return {'backend_id': self.backend_record.id}
|
return {'backend_id': self.backend_record.id}
|
||||||
|
|
||||||
|
@mapping
|
||||||
|
def sync_date(self, record):
|
||||||
|
return {'sync_date': fields.Datetime.now()}
|
||||||
|
|||||||
@@ -33,13 +33,14 @@ class ProductPricelistImporter(Component):
|
|||||||
('external_id', '=', str(plan['id'])),
|
('external_id', '=', str(plan['id'])),
|
||||||
], limit=1)
|
], limit=1)
|
||||||
if not plan_bind:
|
if not plan_bind:
|
||||||
channel_product_listprice_obj.with_context({
|
plan_bind = channel_product_listprice_obj.with_context({
|
||||||
'connector_no_export': True,
|
'connector_no_export': True,
|
||||||
}).create(plan_record.values(for_create=True))
|
}).create(plan_record.values(for_create=True))
|
||||||
else:
|
else:
|
||||||
channel_product_listprice_obj.with_context({
|
plan_bind.with_context({
|
||||||
'connector_no_export': True,
|
'connector_no_export': True,
|
||||||
}).write(plan_record.values())
|
}).write(plan_record.values())
|
||||||
|
self.binder(str(plan['id']), plan_bind)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
|||||||
@@ -72,5 +72,8 @@ class ProductPricelistItemExporter(Component):
|
|||||||
internal_message=str(err),
|
internal_message=str(err),
|
||||||
channel_message=err.data['message'])
|
channel_message=err.data['message'])
|
||||||
else:
|
else:
|
||||||
channel_unpushed.write({'channel_pushed': True})
|
channel_unpushed.write({
|
||||||
|
'channel_pushed': True,
|
||||||
|
'sync_date': fields.Datetime.now(),
|
||||||
|
})
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ class ProductPricelistItemImporter(Component):
|
|||||||
usage='import.mapper',
|
usage='import.mapper',
|
||||||
model_name='channel.product.pricelist.item')
|
model_name='channel.product.pricelist.item')
|
||||||
if pricelist_bind:
|
if pricelist_bind:
|
||||||
_logger.info("==== PASA BIND")
|
|
||||||
channel_pricelist_item_obj = self.env['channel.product.pricelist.item']
|
channel_pricelist_item_obj = self.env['channel.product.pricelist.item']
|
||||||
dfrom_dt = fields.Date.from_string(date_from)
|
dfrom_dt = fields.Date.from_string(date_from)
|
||||||
dto_dt = fields.Date.from_string(date_to)
|
dto_dt = fields.Date.from_string(date_to)
|
||||||
@@ -59,7 +58,6 @@ class ProductPricelistItemImporter(Component):
|
|||||||
('product_tmpl_id', '=',
|
('product_tmpl_id', '=',
|
||||||
channel_room_type.product_id.product_tmpl_id.id)
|
channel_room_type.product_id.product_tmpl_id.id)
|
||||||
], limit=1)
|
], limit=1)
|
||||||
_logger.info("=== ESCRIBEINDO")
|
|
||||||
if pricelist_item:
|
if pricelist_item:
|
||||||
pricelist_item.with_context({
|
pricelist_item.with_context({
|
||||||
'connector_no_export': True,
|
'connector_no_export': True,
|
||||||
@@ -139,3 +137,7 @@ class ProductPricelistItemImportMapper(Component):
|
|||||||
@mapping
|
@mapping
|
||||||
def backend_id(self, record):
|
def backend_id(self, record):
|
||||||
return {'backend_id': self.backend_record.id}
|
return {'backend_id': self.backend_record.id}
|
||||||
|
|
||||||
|
@mapping
|
||||||
|
def sync_date(self, record):
|
||||||
|
return {'sync_date': fields.Datetime.now()}
|
||||||
|
|||||||
@@ -10,16 +10,6 @@ class HotelRoomType(models.Model):
|
|||||||
|
|
||||||
_inherit = 'hotel.room.type'
|
_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
|
@api.model
|
||||||
def get_room_type_availability(self, dfrom, dto, room_type_id):
|
def get_room_type_availability(self, dfrom, dto, room_type_id):
|
||||||
free_rooms = self.check_availability_room_type(dfrom, dto)
|
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])
|
min_stay = max([r['min_stay'] for r in restrictions_plan])
|
||||||
|
|
||||||
return min_stay
|
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}
|
||||||
|
|||||||
Reference in New Issue
Block a user