mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP][MIG][11.0] channel_connector
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# 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
|
||||
|
||||
@@ -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': [
|
||||
|
||||
@@ -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')
|
||||
@@ -1,8 +1,8 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# 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
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<record model="ir.actions.act_window" id="open_hotel_channel_connector_ota_info_tree_all">
|
||||
<field name="name">Hotel Channel Connector OTA's Info</field>
|
||||
<field name="res_model">hotel_channel_connector_ota_info</field>
|
||||
<field name="res_model">hotel.channel.connector.ota.info</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<odoo noupdate="1">
|
||||
|
||||
<record model="ir.sequence" id="seq_room_type_id">
|
||||
<field name="name">Virtual Room Short Code</field>
|
||||
<field name="name">Room Type Short Code</field>
|
||||
<field name="code">hotel.room.type</field>
|
||||
<field name="prefix"></field>
|
||||
<field name="padding">4</field>
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<form string="Hotel Channel Reservation">
|
||||
<group>
|
||||
<field name="channel_reservation_id" />
|
||||
<field name="ota_reservation_code" />
|
||||
<field name="ota_reservation_id" />
|
||||
<field name="wstatus" />
|
||||
<field name="wstatus_reason" />
|
||||
<field name="to_read" />
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<record id="view_channel_hotel_room_type_availability_tree" model="ir.ui.view">
|
||||
<field name="name">channel.hotel.room.type.availability.tree</field>
|
||||
<field name="model">channel.hotel.virtual.availability.room</field>
|
||||
<field name="model">channel.hotel.room.type.availability</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Hotel Channel Room Availability">
|
||||
<field name="backend_id"/>
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<record id="view_channel_hotel_room_type_restriction_tree" model="ir.ui.view">
|
||||
<field name="name">channel.hotel.room.type.restriction.tree</field>
|
||||
<field name="model">channel.hotel.virtual.restriction.room</field>
|
||||
<field name="model">channel.hotel.room.type.restriction</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Hotel Channel Room Restriction">
|
||||
<field name="backend_id"/>
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<record id="view_channel_hotel_room_type_restriction_tree" model="ir.ui.view">
|
||||
<field name="name">channel.hotel.product.pricelist.tree</field>
|
||||
<field name="model">channel.hotel.product.pricelist.room</field>
|
||||
<field name="model">channel.product.pricelist</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Hotel Channel Product Pricelist">
|
||||
<field name="backend_id"/>
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
<!-- FORM issue -->
|
||||
<record id="hotel_channel_connector_issue_view_form" model="ir.ui.view">
|
||||
<field name="name">hotel.channel.coonector.issue.form</field>
|
||||
<field name="model">hotel.channel.coonector.issue</field>
|
||||
<field name="name">hotel.channel.connector.issue.form</field>
|
||||
<field name="model">hotel.channel.connector.issue</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Channel Connector Issue">
|
||||
<sheet>
|
||||
@@ -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]]}"/>
|
||||
</div>
|
||||
<group>
|
||||
<field name="section"/>
|
||||
@@ -37,8 +37,8 @@
|
||||
|
||||
<!-- TREE issue -->
|
||||
<record id="hotel_channel_connector_issue_view_tree" model="ir.ui.view">
|
||||
<field name="name">hotel.channel.coonector.issue.tree</field>
|
||||
<field name="model">hotel.channel.coonector.issue</field>
|
||||
<field name="name">hotel.channel.connector.issue.tree</field>
|
||||
<field name="model">hotel.channel.connector.issue</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Channel Connector Issues">
|
||||
@@ -54,8 +54,8 @@
|
||||
|
||||
<!-- SEARCH issue -->
|
||||
<record id="view_hotel_channel_connector_issue_form_search" model="ir.ui.view">
|
||||
<field name="name">hotel.channel.coonector.issue.search</field>
|
||||
<field name="model">hotel.channel.coonector.issue</field>
|
||||
<field name="name">hotel.channel.connector.issue.search</field>
|
||||
<field name="model">hotel.channel.connector.issue</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Issues">
|
||||
<field name="create_date"/>
|
||||
@@ -21,7 +21,7 @@
|
||||
<!-- Tree view -->
|
||||
<record model="ir.ui.view" id="view_hotel_channel_connector_ota_info_tree">
|
||||
<field name="name">hotel.channel.connector.ota.info.tree</field>
|
||||
<field name="model">hotel.channel.connector.ota.info.info</field>
|
||||
<field name="model">hotel.channel.connector.ota.info</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Channel OTA's Info">
|
||||
<field name="ota_id" />
|
||||
@@ -21,20 +21,20 @@
|
||||
<field name="is_from_ota" invisible="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//notebook/page/field[@name='room_lines']/tree/field[@name='checkout']" position="attributes">
|
||||
<attribute name="attrs">{'readonly': [('wis_from_channel', '!=', False)]}</attribute>
|
||||
<attribute name="attrs">{'readonly': [('is_from_ota', '!=', False)]}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//notebook/page/field[@name='room_lines']/tree/field[@name='checkin']" position="attributes">
|
||||
<attribute name="attrs">{'readonly': [('wis_from_channel', '!=', False)]}</attribute>
|
||||
<attribute name="attrs">{'readonly': [('is_from_ota', '!=', False)]}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//notebook/page/field[@name='room_lines']/form/sheet/header/field[@name='folio_id']" position="after">
|
||||
<field name="origin_sale" invisible="1"/>
|
||||
<field name="is_from_ota" invisible="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//notebook/page/field[@name='room_lines']/form/sheet/h3/field[@name='checkout']" position="attributes">
|
||||
<attribute name="attrs">{'readonly': [('wis_from_channel', '!=', False)]}</attribute>
|
||||
<attribute name="attrs">{'readonly': [('is_from_ota', '!=', False)]}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//notebook/page/field[@name='room_lines']/form/sheet/h3/field[@name='checkin']" position="attributes">
|
||||
<attribute name="attrs">{'readonly': [('wis_from_channel', '!=', False)]}</attribute>
|
||||
<attribute name="attrs">{'readonly': [('is_from_ota', '!=', False)]}</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
<field name="inherit_id" ref="hotel.view_hotel_reservation_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='channel_type']" position="after">
|
||||
<field name="channel_reservation_id" attrs='{"readonly": [("able_to_modify_channel","=",False)], "invisible":[("channel_type","!=", "web")]}' string="OTA"/>
|
||||
<!-- field name="channel_reservation_id" attrs='{"readonly": [("able_to_modify_channel","=",False)], "invisible":[("channel_type","!=", "web")]}' string="OTA"/-->
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='cardex_pending']" position="before">
|
||||
<xpath expr="//field[@name='cardex_pending_count']" position="before">
|
||||
<group colspan="6" col="6">
|
||||
<field name="is_from_ota" readonly="True" invisible="True"/>
|
||||
</group>
|
||||
@@ -39,7 +39,8 @@
|
||||
<attribute name="attrs">{'readonly': [('is_from_ota','=',True),('able_to_modify_channel','=',False)]}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='room_type_id']" position="attributes">
|
||||
<attribute name="attrs">{'readonly': [('channel_reservation_id','!=',False),('able_to_modify_channel','=',False)]}</attribute>
|
||||
<!-- attribute name="attrs">{'readonly': [('channel_reservation_id','!=',False),('able_to_modify_channel','=',False)]}</attribute-->
|
||||
<attribute name="attrs">{'readonly': [('able_to_modify_channel','=',False)]}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='children']" position="attributes">
|
||||
<attribute name="attrs">{'readonly': [('is_from_ota','=',True),('able_to_modify_channel','=',False)]}</attribute>
|
||||
@@ -74,7 +75,7 @@
|
||||
<field name="inherit_id" ref="hotel.view_hotel_reservation_search" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='folio_id']" position="after">
|
||||
<field name="wchannel_reservation_code"/>
|
||||
<!-- field name="wchannel_reservation_code"/-->
|
||||
</xpath>
|
||||
<xpath expr="//group" position="inside">
|
||||
<filter name="origin" string="Origin" domain="[]"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<odoo>
|
||||
|
||||
<!-- FORM availability -->
|
||||
<record id="room_type_availability_view_form" model="ir.ui.view">
|
||||
<record id="room_type_availability_view_form" model="ir.ui.view">
|
||||
<field name="model">hotel.room.type.availability</field>
|
||||
<field name="inherit_id" ref="hotel.room_type_availability_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
@@ -23,14 +23,15 @@
|
||||
</record>
|
||||
|
||||
<!-- TREE restriction -->
|
||||
<record id="room_type_availability_view_tree" model="ir.ui.view">
|
||||
<field name="model">hotel.room.type.availability</field>
|
||||
<field name="inherit_id" ref="hotel.room_type_availability_view_tree" />
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<!-- <xpath expr="//field[@name='avail']" position="after">
|
||||
<field name="channel_max_avail" />
|
||||
</xpath> -->
|
||||
</field>
|
||||
</record>
|
||||
<!--record id="room_type_availability_view_tree" model="ir.ui.view">
|
||||
<field name="model">hotel.room.type.availability</field>
|
||||
<field name="inherit_id" ref="hotel.room_type_availability_view_tree" />
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='avail']" position="after">
|
||||
<field name="channel_max_avail" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record-->
|
||||
|
||||
</odoo>
|
||||
@@ -6,7 +6,7 @@
|
||||
<field name="inherit_id" ref="product.product_pricelist_item_form_view" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='name']" position="after">
|
||||
<field name="channel_pushed" readonly="True" />
|
||||
<!--field name="channel_pushed" readonly="True" /-->
|
||||
<field name="is_daily_plan" invisible="1" />
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='date_end']" position="attributes">
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form[1]//sheet" position="before">
|
||||
<header>
|
||||
<button name="%(action_channel_import_plan_prices)d" string="Import Prices From Channel" type="action" class="oe_highlight" />
|
||||
<button name="%(action_wubook_import_plan_prices)d" string="Import Prices From Channel" type="action" class="oe_highlight" />
|
||||
</header>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='company_id']" position="after">
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form[1]//sheet" position="before">
|
||||
<header>
|
||||
<button name="%(action_channel_import_plan_restrictions)d" string="Import Restrictions From Channel" type="action" class="oe_highlight" />
|
||||
<button name="%(action_wubook_import_plan_restrictions)d" string="Import Restrictions From Channel" type="action" class="oe_highlight" />
|
||||
</header>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<field name="set_wmax_avail" />
|
||||
<field name="set_max_avail" />
|
||||
</group>
|
||||
<footer>
|
||||
<button name="import_availability" string="Import" type="object"
|
||||
|
||||
@@ -81,10 +81,10 @@
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record id="wubook_configuration_installer_todo" model="ir.actions.todo">
|
||||
<!--record id="wubook_configuration_installer_todo" model="ir.actions.todo">
|
||||
<field name="action_id" ref="action_wubook_configuration_installer"/>
|
||||
<field name="sequence">3</field>
|
||||
<field name="type">automatic</field>
|
||||
</record>
|
||||
</record-->
|
||||
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user