mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] button for channel binding management
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, models, fields, _
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.addons import decimal_precision as dp
|
||||
from odoo.addons.queue_job.job import job
|
||||
@@ -111,6 +112,27 @@ class HotelRoomType(models.Model):
|
||||
], limit=1)
|
||||
return restriction
|
||||
|
||||
@api.multi
|
||||
def open_channel_bind_ids(self):
|
||||
channel_bind_ids = self.mapped('channel_bind_ids')
|
||||
action = self.env.ref('hotel_channel_connector.channel_hotel_room_type_action').read()[0]
|
||||
action['views'] = [(self.env.ref('hotel_channel_connector.channel_hotel_room_type_view_form').id, 'form')]
|
||||
if len(channel_bind_ids) == 1:
|
||||
action['res_id'] = channel_bind_ids.ids[0]
|
||||
elif len(channel_bind_ids) > 1:
|
||||
# WARNING: more than one binding is currently not expected
|
||||
action['domain'] = [('id', 'in', channel_bind_ids.ids)]
|
||||
else:
|
||||
action['target'] = 'new'
|
||||
return action
|
||||
|
||||
@api.multi
|
||||
def sync_from_channel(self):
|
||||
channel_bind_ids = self.mapped('channel_bind_ids')
|
||||
msg = _("Synchronize room types from the channel manager is not yet implementet.")
|
||||
raise UserError(msg)
|
||||
|
||||
|
||||
class BindingHotelRoomTypeListener(Component):
|
||||
_name = 'binding.hotel.room.type.listener'
|
||||
_inherit = 'base.connector.listener'
|
||||
|
||||
@@ -8,9 +8,10 @@
|
||||
<form string="Hotel Channel Virtual Room">
|
||||
<group>
|
||||
<field name="id" invisible="1" />
|
||||
<field name="backend_id" attrs="{'visible': [('id','=', False)]}" />
|
||||
<field name="backend_id" attrs="{'visible': [('id','=', False)], 'readonly': [('id','!=', False)]}" />
|
||||
</group>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="external_id" />
|
||||
<field name="channel_short_code" />
|
||||
<field name="ota_capacity" />
|
||||
@@ -33,4 +34,12 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="channel_hotel_room_type_action" model="ir.actions.act_window">
|
||||
<field name="name">Hotel Channel Connector Bindings</field>
|
||||
<field name="res_model">channel.hotel.room.type</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="domain">[]</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -5,23 +5,16 @@
|
||||
<field name="model">hotel.room.type</field>
|
||||
<field name="inherit_id" ref="hotel.hotel_room_type_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='board_service_room_type_ids']/tree" position="inside">
|
||||
<field name="channel_service" />
|
||||
<xpath expr="//button[@name='toggle_active']" position="before">
|
||||
<button name="open_channel_bind_ids" type="object"
|
||||
class="oe_stat_button" icon="fa-cloud-upload" string="Export to Channel"/>
|
||||
<button name="sync_from_channel" type="object"
|
||||
class="oe_stat_button" icon="fa-cloud-download" string="Import from Channel"
|
||||
confirm="Synchronizing a room type automatically updates its values in Odoo. Do you want to proceed?"/>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//sheet" position="inside">
|
||||
<notebook>
|
||||
<page name="connector" string="Channel Connector">
|
||||
<group string="Hotel Channel Bindings">
|
||||
<field name="capacity" invisible="1" />
|
||||
<field name="channel_bind_ids" context="{'default_ota_capacity': capacity}" nolabel="1">
|
||||
<tree>
|
||||
<field name="backend_id" />
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
<xpath expr="//field[@name='board_service_room_type_ids']/tree" position="inside">
|
||||
<field name="channel_service" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user